#!/usr/local/bin/bash # # FILE : dotfiles.sys/new-machine.setup.sh # TARGET: none # AUTHOR: tgwil # # This script sets up a new machine. # It includes only things necessary for EVERY machine. # # This installer assumes that: # - this repository is cloned to /usr/local/share/dotfiles.sys # - /usr/local/share/dotfiles.sys/ is owned by root # - the installer is being run by a user with sudo privileges ######################################################################## ## Setup ######################################################################## # Set script output colors GREEN="\e[32m" YELLOW="\e[33m" WARN="\e[1;31m" ENDCOLOR="\e[0m" # Check if running as root if [[ "${EUID}" -ne 0 ]]; then echo -e "${WARN}WARNING: This script requires root privileges${ENDCOLOR}" echo -e "INFO : Abort!" exit 1 else # Startup message echo "### Starting dotfiles.sys installation... ###" fi # Give user the chance to abort before shit starts happening. echo -e "${WARN}WARNING: This installer is meant for new machines. It will replace system-level configuration files. [A]bort, [C]ontinue: ${ENDCOLOR}" echo -en "\033[1A\033[1000C" read -n1 confirm confirm_invalid_selection=0 while case $confirm in "a"|"A") echo "INFO : Abort!" exit 0;; "c"|"C") break;; *) echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}" confirm_invalid_selection=1;; esac [[ $confirm_invalid_selection==1 ]] do true; done ######################################################################## ## Install Packages ######################################################################## echo "INFO : Proceed with package installation? [y/n]: " echo -en "\033[1A\033[1000C" read -n1 do_package_install package_invalid_selection=0 while case $do_package_install in "y"|"Y") pkg update pkg upgrade && sudo pkg install \ devel/autotools \ devel/cmake \ devel/git \ devel/libvterm \ devel/pkgconf \ devel/roswell \ editors/emacs \ editors/nano \ ports-mgmt/portconfig \ security/gnupg \ security/sudo \ shells/bash \ shells/bash-completion \ sysutils/coreutils \ sysutils/dmidecode \ sysutils/exa \ sysutils/gdisk echo "INFO : Packages installed and updated." break;; "n"|"N") echo "INFO : Skipping package installation and updates." break;; *) echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}" package_invalid_selection=1;; esac [[ $package_invalid_selection==1 ]] do true; done