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. --- README.md | 18 ++++-------- new-user-setup.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 13 deletions(-) create mode 100755 new-user-setup.sh diff --git a/README.md b/README.md index 7dc2dba..9c921df 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,11 @@ My other dotfiles: - [dotfiles.sys](http://git.tgwil.net/dotfiles.sys/) for system configurations. ## Installation -### Clone this repository -```bash -cd -git clone git@git.tgwil.net:dotfiles.core dotfiles.core -``` -### Install the files +The `new-user-setup.sh` script is all that is needed to setup a new user account. To run the script: ```bash -cd - -# install .bash_profile -ln -s $HOME/dotfiles.core/home/.bash_profile $HOME/.bash_profile - -# install .bashrc -ln -s $HOME/dotfiles.core/home/.bashrc $HOME/.bashrc +cd ~/dotfiles.core +./new-user-setup.sh ``` + +If the script cannot be run for whatever reason, it is sufficiently documented to use it as a guide for manual installation. 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