-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
71 lines (57 loc) · 1.33 KB
/
install.sh
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
#!/bin/bash
#####################
# Managed files #
#####################
files="vim
vimrc
zshrc
bashrc
screenrc
git_prompt.zsh
ctags
tmux.conf"
cd "$(dirname "${BASH_SOURCE}")"
filename=$HOME/backup_$(date +%b_%d_%Y_%H_%M_%S)
backup () {
echo
read -p "Press [Enter] key to start backup..."
#Backup
mkdir $filename
for file in $files; do
echo "Backing up $HOME/.$file ..."
mv $HOME/.$file $filename 2> /dev/null
done
echo
echo "Backed up configuration files in: $filename"
}
doIt () {
echo
read -p "Press [Enter] key to start install..."
for file in $files; do
echo "Copying $HOME/.$file ..."
rsync -avzrq $file $HOME/.$file
done
}
## Start ##
if [ -d ".git" ] ; then
git pull
fi
if [ ! -d $filename ]; then
read -p "Some of your existing configuration files might be overwritten.
Would you like a backup of your current installation?
y: Backup and clean install
u: Update existing files (WARNING: no backup)
n: Abort " yun
while true; do
case $yun in
[Yy]* ) backup; doIt; exit;;
[Uu]* ) doIt; exit;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "Cannot create backup file: '$filename' already exists"
exit
fi
unset doIt