blob: 072404bde21b056509be6b7d023a32b421eaea30 (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!/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.
# Messages passed to the user by this script are in 8-char columns.
#Created:
#Removed:
#Moved :
#Skipped:
#
#ERROR :
#WARNING:
#INFO :
#
#File :
#Dir :
#Symlink:
########################################################################
## 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 "### Starting dotfiles.core installation... ###"
########################################################################
## Put files into place
########################################################################
# File placement function
place_file () {
file=$1
target=$2
if [[ -e $target ]]; then
echo -e \
"${WARN}WARNING: File : ${target} already exists!" \
"[A]bort, [D]elete, [R]eplace, [S]kip: ${ENDCOLOR}"
invalid_selection=0
while
# The following echo fixes read's annoying newline that
# messes up my nice script formatting. It sends cursor back
# to the "target already exists" line.
# \033[1A moves up to previous line.
# \033[1000C moves to the last column in the line up to 1000.
echo -en "\033[1A\033[1000C"
read -n1 selection
case $selection in
"a"|"A")
echo "INFO : Abort!"
exit 0;;
"d"|"D")
rm -fv $target
echo -e "${YELLOW}Removed: File : ${target}${ENDCOLOR}"
ln -s $file $target
echo -e "${GREEN}Created: Symlink: ${target} -> ${file}${ENDCOLOR}"
return 0;;
"r"|"R")
mv -f $target $target.bak
echo -e "${YELLOW}Moved : File : ${target} to ${target}.bak${ENDCOLOR}"
ln -s $file $target
echo -e "${GREEN}Created: Symlink: ${target} -> ${file}${ENDCOLOR}"
return 0;;
"s"|"S")
echo -e "${YELLOW}Skipped: File : ${target}${ENDCOLOR}"
return 0;;
*)
echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}"
invalid_selection=1;;
esac
[[ $invalid_selection==1 ]]
do true; done
else
ln -s $file $target
echo -e "${GREEN}Created: File : ${target} -> ${file}${ENDCOLOR}"
fi
}
# Directory placement function
place_directory () {
target=$1
if [[ -d $target ]]; then
echo -e \
"${WARN}WARNING: Dir : ${target} already exists!" \
"[A]bort, [D]elete, [R]eplace, [S]kip: ${ENDCOLOR}"
invalid_selection=0
while
# The following echo fixes read's annoying newline that
# messes up my nice script formatting. It sends cursor back
# to the "target already exists" line.
# \033[1A moves up to previous line.
# \033[1000C moves to the last column in the line up to 1000.
echo -en "\033[1A\033[1000C"
read -n1 selection
case $selection in
"a"|"A")
echo "INFO : Abort!"
exit 0;;
"d"|"D")
rm -rf $target
echo -e "${YELLOW}Removed: Dir : ${target}${ENDCOLOR}"
mkdir -p $target
echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}"
return 0;;
"r"|"R")
mv -f $target $target.bak
echo -e "${YELLOW}Moved : Dir : ${target} to ${target}.bak${ENDCOLOR}"
mkdir -p $target
echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}"
return 0;;
"s"|"S")
echo -e "${YELLOW}Skipped: Dir : ${target}${ENDCOLOR}"
return 0;;
*)
echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}"
invalid_selection=1;;
esac
[[ $invalid_selection==1 ]]
do true; done
else
mkdir -p $target
echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}"
fi
}
# Bash Configuration
place_file $HOME/dotfiles.core/home/.bash_profile $HOME/.bash_profile
place_file $HOME/dotfiles.core/home/.bashrc $HOME/.bashrc
place_file $HOME/dotfiles.core/home/.bash_aliases $HOME/.bash_aliases
# GPG Configuration
place_directory $HOME/.gnupg/
place_file $HOME/dotfiles.core/home/.gnupg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf
########################################################################
## END OF SCRIPT
########################################################################
echo -e "INFO : Installation completed: dotfiles.core"
|