Refactors install script

This commit is contained in:
Alicia Sykes 2022-11-10 05:46:14 +00:00
parent 9350354b1d
commit 0380b7799d

View File

@ -69,32 +69,32 @@ make_banner () {
make_intro () { make_intro () {
C2="\033[0;35m" C2="\033[0;35m"
C3="\x1b[2m" C3="\x1b[2m"
echo -e "${CYAN_B}The seup script will do the following:${RESET}" echo -e "${CYAN_B}The seup script will do the following:${RESET}\n"\
echo -e "${C2}(1) Pre-Setup Tasls" "${C2}(1) Pre-Setup Tasls\n"\
echo -e " ${C3}- Check that all requirements are met, and system is compatible" " ${C3}- Check that all requirements are met, and system is compatible\n"\
echo -e " ${C3}- Sets environmental variables from params, or uses sensible defaults" " ${C3}- Sets environmental variables from params, or uses sensible defaults\n"\
echo -e " ${C3}- Output welcome message" " ${C3}- Output welcome message\n"\
echo -e "${C2}(2) Setup Dotfiles" "${C2}(2) Setup Dotfiles\n"\
echo -e " ${C3}- Clone or update dotfiles from git" " ${C3}- Clone or update dotfiles from git\n"\
echo -e " ${C3}- Symlinks dotfiles to correct locations" " ${C3}- Symlinks dotfiles to correct locations\n"\
echo -e "${C2}(3) Install packages" "${C2}(3) Install packages\n"\
echo -e " ${C3}- On MacOS, prompt to install Homebrew if not present" " ${C3}- On MacOS, prompt to install Homebrew if not present\n"\
echo -e " ${C3}- On MacOS, updates and installs apps liseted in Brewfile" " ${C3}- On MacOS, updates and installs apps liseted in Brewfile\n"\
echo -e " ${C3}- On Arch Linux, updates and installs packages via Pacman" " ${C3}- On Arch Linux, updates and installs packages via Pacman\n"\
echo -e " ${C3}- On Debian Linux, updates and installs packages via apt get" " ${C3}- On Debian Linux, updates and installs packages via apt get\n"\
echo -e " ${C3}- On Linux desktop systems, prompt to install desktop apps via Flatpak" " ${C3}- On Linux desktop systems, prompt to install desktop apps via Flatpak\n"\
echo -e " ${C3}- Checks that OS is up-to-date and criticial patches are installed" " ${C3}- Checks that OS is up-to-date and criticial patches are installed\n"\
echo -e "${C2}(4) Configure sytstem" "${C2}(4) Configure sytstem\n"\
echo -e " ${C3}- Setup Vim, and install Vim plugins via Plug" " ${C3}- Setup Vim, and install Vim plugins via Plug\n"\
echo -e " ${C3}- Setup Tmux, and install Tmux plugins via TPM" " ${C3}- Setup Tmux, and install Tmux plugins via TPM\n"\
echo -e " ${C3}- Setup ZSH, and install ZSH plugins via Antigen" " ${C3}- Setup ZSH, and install ZSH plugins via Antigen\n"\
echo -e " ${C3}- Prompt to configure OS user preferences" " ${C3}- Prompt to configure OS user preferences\n"\
echo -e "${C2}(5) Finishing Up" "${C2}(5) Finishing Up\n"\
echo -e " ${C3}- Refresh current terminal session" " ${C3}- Refresh current terminal session\n"\
echo -e " ${C3}- Print summary of applied changes and time taken" " ${C3}- Print summary of applied changes and time taken\n"\
echo -e " ${C3}- Exit with appropriate status code" " ${C3}- Exit with appropriate status code\n\n"\
echo -e "\n${PURPLE}You will be prompted at each stage, before any changes are made.${RESET}" "${PURPLE}You will be prompted at each stage, before any changes are made.${RESET}\n"\
echo -e "${PURPLE}For more info, see GitHub: \033[4;35mhttps://github.com/lissy93/dotfiles${RESET}" "${PURPLE}For more info, see GitHub: \033[4;35mhttps://github.com/${REPO_NAME}${RESET}"
} }
# Cleanup tasks, run when the script exits # Cleanup tasks, run when the script exits
@ -180,7 +180,8 @@ function setup_dot_files () {
# Download / update dotfiles repo with git # Download / update dotfiles repo with git
if [[ ! -d "$DOTFILES_DIR" ]] if [[ ! -d "$DOTFILES_DIR" ]]
then then
echo -e "${PURPLE}Dotfiles not yet present. Will download ${REPO_NAME} into ${DOTFILES_DIR}${RESET}" echo -e "${PURPLE}Dotfiles not yet present. \
Will download ${REPO_NAME} into ${DOTFILES_DIR}${RESET}"
mkdir -p "${DOTFILES_DIR}" mkdir -p "${DOTFILES_DIR}"
git clone --recursive ${DOTFILES_REPO} ${DOTFILES_DIR} git clone --recursive ${DOTFILES_REPO} ${DOTFILES_DIR}
else else
@ -194,7 +195,7 @@ function setup_dot_files () {
ret=$? ret=$?
if ! test "$ret" -eq 0 if ! test "$ret" -eq 0
then then
echo >&2 "${RED_B}Failed to fetch dotfiels $ret${RESET}" echo -e >&2 "${RED_B}Failed to fetch dotfiels $ret${RESET}"
terminate terminate
fi fi
@ -240,14 +241,16 @@ function apply_preferences () {
fi fi
# Apply general system, app and OS security preferences (prompt user first) # Apply general system, app and OS security preferences (prompt user first)
echo -e "${CYAN_B}Would you like to apply system preferences? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to apply system preferences? (y/N)${RESET}"
read -t $PROMPT_TIMEOUT -n 1 -r ans_syspref read -t $PROMPT_TIMEOUT -n 1 -r ans_syspref
if [[ $ans_syspref =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]]; then if [[ $ans_syspref =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]]; then
if [ "$SYSTEM_TYPE" = "Darwin" ]; then if [ "$SYSTEM_TYPE" = "Darwin" ]; then
echo -e "\n${PURPLE}Applying MacOS system preferences, ensure you've understood before proceeding${RESET}\n" echo -e "\n${PURPLE}Applying MacOS system preferences,\
ensure you've understood before proceeding${RESET}\n"
macos_settings_dir="$DOTFILES_DIR/scripts/macos-setup" macos_settings_dir="$DOTFILES_DIR/scripts/macos-setup"
for macScript in "macos-security.sh" "macos-preferences.sh" "macos-apps.sh"; do for macScript in "macos-security.sh" "macos-preferences.sh" "macos-apps.sh"; do
chmod +x $macos_settings_dir/$macScript && $macos_settings_dir/$macScript --quick-exit chmod +x $macos_settings_dir/$macScript && \
$macos_settings_dir/$macScript --quick-exit --yes-to-all
done done
fi fi
fi fi
@ -261,7 +264,8 @@ function intall_macos_packages () {
read -t $PROMPT_TIMEOUT -n 1 -r ans_homebrewins read -t $PROMPT_TIMEOUT -n 1 -r ans_homebrewins
if [[ $ans_homebrewins =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_homebrewins =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
echo -en "🍺 ${PURPLE}Installing Homebrew...${RESET}\n" echo -en "🍺 ${PURPLE}Installing Homebrew...${RESET}\n"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew_url='https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh'
/bin/bash -c "$(curl -fsSL $brew_url)"
export PATH=/opt/homebrew/bin:$PATH export PATH=/opt/homebrew/bin:$PATH
fi fi
fi fi
@ -353,6 +357,14 @@ function finishing_up () {
# Refresh ZSH sesssion # Refresh ZSH sesssion
SKIP_WELCOME=true || exec zsh SKIP_WELCOME=true || exec zsh
# Show popup
if command_exists terminal-notifier; then
terminal-notifier -group 'dotfiles' -title $TITLE -subtitle 'All Tasks Complete' \
-message "Your dotfiles are now configured and ready to use 🥳" \
-appIcon ./.github/logo.png -contentImage ./.github/logo.png \
-remove 'ALL' -sound 'Sosumi' &> /dev/null
fi
# Show press any key to exit # Show press any key to exit
echo -e "${CYAN_B}Press any key to exit.${RESET}\n" echo -e "${CYAN_B}Press any key to exit.${RESET}\n"
read -t $PROMPT_TIMEOUT -n 1 -s read -t $PROMPT_TIMEOUT -n 1 -s