aboutsummaryrefslogtreecommitdiff
path: root/new-user-setup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'new-user-setup.sh')
-rwxr-xr-xnew-user-setup.sh85
1 files changed, 85 insertions, 0 deletions
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 @@
1#!/usr/local/bin/bash
2#
3# FILE : dotfiles.core/new-account-setup.sh
4# TARGET: none
5# AUTHOR: tgwil
6#
7# This script sets up a new account. As this is the dotfiles.core
8# installer, only things which apply to every account are done here.
9#
10# This installer assumes that the dotfiles.core repository has been
11# cloned into the $HOME directory under the name 'dotfiles.core'. It
12# should be cloned and run this way for every new user.
13
14
15########################################################################
16## Setup
17########################################################################
18# Return to home
19cd
20
21# Set script output colors
22GREEN="\e[32m"
23YELLOW="\e[33m"
24WARN="\e[1;31m"
25ENDCOLOR="\e[0m"
26
27
28# Startup message
29echo ""
30echo "### Starting dotfiles.core installation... ###"
31
32
33########################################################################
34## Put files into place
35########################################################################
36# File placement function
37place_file () {
38 file=$1
39 target=$2
40 if [[ -e $target ]]; then
41 echo -e "\n${WARN}WARNING: ${target} already exists!${ENDCOLOR}"
42 invalid_selection=0
43 while
44 read -p "[A]bort, [D]elete, [R]eplace, [S]kip: " -n1 selection
45 echo ""
46 case $selection in
47 "a"|"A")
48 echo "Abort!"
49 exit 0;;
50 "d"|"D")
51 rm -fv $target
52 echo -e "${YELLOW}Removed ${target}${ENDCOLOR}"
53 ln -s $file $target
54 echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}"
55 return 0;;
56 "r"|"R")
57 mv -f $target $target.bak & \
58 echo -e "${YELLOW}Moved: ${target} to ${target}.bak${ENDCOLOR}"
59 ln -s $file $target & \
60 echo -e "${GREEN}Created: ${target} -> ${file}${ENDCOLOR}"
61 return 0;;
62 "s"|"S")
63 echo -e "${YELLOW}Skipping ${target}${ENDCOLOR}"
64 return 0;;
65 *)
66 echo -e "${WARN}Invalid selection, try again...${ENDCOLOR}"
67 invalid_selection=1;;
68 esac
69 [[ $invalid_selection==1 ]]
70 do true; done
71 else
72 ln -s $file $target
73 echo -e "\n${GREEN}Created: ${target} -> ${file}${ENDCOLOR}"
74 fi
75}
76
77# Place files
78place_file $HOME/dotfiles.core/home/.bash_profile $HOME/.bash_profile
79place_file $HOME/dotfiles.core/home/.bashrc $HOME/.bashrc
80
81
82########################################################################
83## END OF SCRIPT
84########################################################################
85echo -e "\nInstallation completed: dotfiles.core\n"