-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
50 lines (40 loc) · 1.11 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
#!/bin/sh
#
# Modeled after https://github.com/holman/dotfiles/blob/master/Rakefile
symlinks=$(find . -name "*.symlink")
overwrite_all=false
backup_all=false
for file in $symlinks; do
overwrite=false
backup=false
basename=$(basename $file .symlink)
target="$HOME/$basename"
if [ -e "$target" ] || [ -h "$target" ]; then
if ! $overwrite_all && ! $backup_all; then
while true; do
echo "$target already exists"
echo "[s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all "
read answer
case $answer in
"s" ) continue 2;; # continue the outer for loop
"S" ) break 2;; # break out of the outer for loop
"o" ) overwrite=true; break;;
"O" ) overwrite_all=true; break;;
"b" ) backup=true; break;;
"B" ) backup_all=true; break;;
* ) continue ;;
esac
done
fi
if $overwrite || $overwrite_all; then
rm $target
fi
if $backup || $backup_all; then
mv $target "$HOME/$basename.backup"
fi
fi
echo "Installing $target"
ln -s "$PWD/$file" "$target"
done
set -e
find . -name "*.install" | while read installer ; do sh -c "${installer}" ; done