From 28350a245e30866303a634744e6e68e63394e420 Mon Sep 17 00:00:00 2001 From: Tristan Williams Date: Mon, 21 Oct 2024 03:34:47 -0400 Subject: Initial commit --- new-machine-setup.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 new-machine-setup.sh (limited to 'new-machine-setup.sh') diff --git a/new-machine-setup.sh b/new-machine-setup.sh new file mode 100755 index 0000000..d1ea488 --- /dev/null +++ b/new-machine-setup.sh @@ -0,0 +1,96 @@ +#!/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 -- cgit v1.2.3