From 8fbd3799177c410e62e37b6bf28515ac4b8ac497 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 21 Sep 2018 13:33:11 -0400 Subject: [PATCH] Add common and bootstrap scripts This commit adds a post-install bootstrap script meant to be run on a user's local account in order to install packages, configure dotfiles, and perform other setup tasks. It may be ideal to use one universal bootstrap script instead of two unique ones since both share many similar characteristics. --- scripts/006-common | 51 +++++++++++++++++++++++++++++ scripts/arch/005-bootstrap | 62 ++++++++++++++++++++++++++++++++++++ scripts/fedora/005-bootstrap | 48 ++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 scripts/006-common create mode 100644 scripts/arch/005-bootstrap create mode 100644 scripts/fedora/005-bootstrap diff --git a/scripts/006-common b/scripts/006-common new file mode 100644 index 00000000..d1a8fd04 --- /dev/null +++ b/scripts/006-common @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Common commands used to configure installed software. + +set -xe + +# Configure yarn +if hash yarn 2>/dev/null; then + echo 'Found yarn. Configuring it...' + yarn config set prefix /usr/local + yarn config set -- --emoji true +fi + +# Set up a rust toolchain +if hash rustup 2>/dev/null; then + echo 'Found rust. Configuring the default toolchain...' + rustup install stable + rustup default stable +fi + +# Start and enable docker +if hash docker 2>/dev/null; then + echo 'Found docker. Requesting administrative rights to configure the service...' + sudo systemctl start docker.service + sudo systemctl enable docker.service +fi + +# Install vim plugins and make the undo directory +if hash vim 2>/dev/null; then + echo 'Found vim. Making directory for global undo and installing plugins...' + mkdir -p ~/.vim/undo + curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + # TODO: Prompt for confirmation before running this script + vim +PlugInstall +qall +fi + +# https://github.com/masterkorp/openvpn-update-resolv-conf +# Note that openresolv should already be installed by netctl. +if hash openvpn 2>/dev/null; then + echo 'Found openvpn. Downloading open-resolv-conf.sh...' + sudo curl -fLo /etc/openvpn/update-resolv-conf.sh --create-dirs \ + https://raw.githubusercontent.com/masterkorp/openvpn-update-resolv-conf/master/update-resolv-conf.sh + # TODO: Prompt for confirmation that the script is valid +fi + +# Add user dirs if they don't exist yet (Desktop, Downloads, etc.) +if hash xdg-user-dirs-update 2>/dev/null; then + echo 'Found xdg-user-dirs. Attempting to create directories...' + xdg-user-dirs-update +fi diff --git a/scripts/arch/005-bootstrap b/scripts/arch/005-bootstrap new file mode 100644 index 00000000..e0a4e6f3 --- /dev/null +++ b/scripts/arch/005-bootstrap @@ -0,0 +1,62 @@ +#!/bin/sh + +set -xe + +# Change the working directory to the location of this script +# Then, move up to the root directory of the git repo +cd "$(dirname "$0")" +cd ../.. + +# Raise an error if no environment is given +if [ "$#" -ne 1 ]; then + echo 'Usage: sh ./path/to/bootstrap ' + exit 1 +fi + +# Install common packages if tig isn't found (one of the common packages) +if ! hash tig 2>/dev/null; then + echo 'Installing common packages...' + sudo pacman -Syu --needed - < ./packages/arch/common + + echo 'Stowing common dotfiles...' + stow -S common --dir=dots --target=$HOME --no-folding --verbose=2 + + echo 'Configuring common packages...' + sh ./scripts/006-common +fi + +# Install yay if it isn't found (needed for AUR and bspwm) +if ! hash yay 2>/dev/null; then + echo 'Installing yay...' + git clone https://aur.archlinux.org/yay-bin.git + cd yay-bin + makepkg -si + cd .. + rm -r yay-bin +fi + +# Install plasma +if [ $1 == "plasma" ]; then + echo 'Installing plasma packages...' + sudo pacman -Syu --needed --ignore discover - < ./packages/arch/plasma + + exit 0 +fi + +# Install bspwm +if [ $1 == "bspwm" ]; then + echo 'Installing bspwm packages...' + sudo pacman -Syu --needed - < ./packages/arch/bspwm + + echo 'Installing bspwm packages from AUR...' + yay -S polybar rtv shotgun launch-cmd + + echo 'Stowing bspwm dotfiles...' + stow -S bspwm --dir=dots --target=$HOME --no-folding --verbose=2 + + exit 0 +fi + +# Throw an error if the script couldn't find a valid environment to use +echo 'Invalid environment specified. Must be either "plasma" or "bspwm"' +exit 1 diff --git a/scripts/fedora/005-bootstrap b/scripts/fedora/005-bootstrap new file mode 100644 index 00000000..9b9d9740 --- /dev/null +++ b/scripts/fedora/005-bootstrap @@ -0,0 +1,48 @@ +#!/bin/sh + +set -xe + +# Change the working directory to the location of this script +# Then, move up to the root directory of the git repo +cd "$(dirname "$0")" +cd ../.. + +# Raise an error if no environment is given +if [ "$#" -ne 1 ]; then + echo 'Usage: sh ./path/to/bootstrap ' + exit 1 +fi + +# Install common packages if tig isn't found (one of the common packages) +if ! hash tig 2>/dev/null; then + echo 'Installing common packages...' + sudo dnf install $(cat ./packages/fedora/common) --assumeyes + + echo 'Stowing common dotfiles...' + stow -S common --dir=dots --target=$HOME --no-folding --verbose=2 + + echo 'Configuring common packages...' + sh ./scripts/006-common +fi + +# Install gnome packages +if [ $1 == "gnome" ]; then + echo 'Installing gnome packages...' + sudo dnf install $(cat ./packages/fedora/gnome) --assumeyes + + echo 'Now that the gnome packages are installed, you must set it up manually.' + exit 0 +fi + +# Install xfce packages +if [ $1 == "xfce" ]; then + echo 'Installing xfce packages...' + sudo dnf install $(cat ./packages/fedora/xfce) --assumeyes + + echo 'Now that the xfce packages are installed, you must set it up manually.' + exit 0 +fi + +# Throw an error if the script couldn't find a valid environment to use +echo 'Invalid environment specified. Must be either "gnome" or "xfce"' +exit 1