blob: 2c635ae5f965a74efcfd280fee123c22820bcc16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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"
|