#!/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"