From 62a07652483f498d89b8972c0edb7772a050ad62 Mon Sep 17 00:00:00 2001 From: Tristan Williams Date: Sat, 12 Oct 2024 19:23:45 -0400 Subject: Create installer The whole point of these dotfiles repos is to automate setup. Might as well have an installer. --- new-user-setup.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 new-user-setup.sh (limited to 'new-user-setup.sh') diff --git a/new-user-setup.sh b/new-user-setup.sh new file mode 100755 index 0000000..2c635ae --- /dev/null +++ b/new-user-setup.sh @@ -0,0 +1,85 @@ +#!/usr/local/bin/bash +# +# FILE : dotfiles.core/new-account-setup.sh +# TARGET: none +# AUTHOR: tgwil +# +# This script sets up a new account. As this is the dotfiles.core +# installer, only things which apply to every account are done here. +# +# This installer assumes that the dotfiles.core repository has been +# cloned into the $HOME directory under the name 'dotfiles.core'. It +# should be cloned and run this way for every new user. + + +######################################################################## +## Setup +######################################################################## +# Return to home +cd + +# Set script output colors +GREEN="\e[32m" +YELLOW="\e[33m" +WARN="\e[1;31m" +ENDCOLOR="\e[0m" + + +# Startup message +echo "" +echo "### Starting dotfiles.core installation... ###" + + +######################################################################## +## Put files into place +######################################################################## +# File placement function +place_file () { + file=$1 + target=$2 + if [[ -e $target ]]; then + echo -e "\n${WARN}WARNING: ${target} already exists!${ENDCOLOR}" + invalid_selection=0 + while + read -p "[A]bort, [D]elete, [R]eplace, [S]kip: " -n1 selection + echo "" + case $selection in + "a"|"A") + echo "Abort!" + exit 0;; + "d"|"D") + rm -fv $target + echo -e "${YELLOW}Removed ${target}${ENDCOLOR}" + ln -s $file $target + echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" + return 0;; + "r"|"R") + mv -f $target $target.bak & \ + echo -e "${YELLOW}Moved: ${target} to ${target}.bak${ENDCOLOR}" + ln -s $file $target & \ + echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" + return 0;; + "s"|"S") + echo -e "${YELLOW}Skipping ${target}${ENDCOLOR}" + return 0;; + *) + echo -e "${WARN}Invalid selection, try again...${ENDCOLOR}" + invalid_selection=1;; + esac + [[ $invalid_selection==1 ]] + do true; done + else + ln -s $file $target + echo -e "\n${GREEN}Created: ${target} -> ${file}${ENDCOLOR}" + fi +} + +# Place files +place_file $HOME/dotfiles.core/home/.bash_profile $HOME/.bash_profile +place_file $HOME/dotfiles.core/home/.bashrc $HOME/.bashrc + + +######################################################################## +## END OF SCRIPT +######################################################################## +echo -e "\nInstallation completed: dotfiles.core\n" -- cgit v1.2.3