-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·58 lines (42 loc) · 1.1 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
#!/bin/bash
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
FILES=$( find $DIR/* $DIR/config/* -maxdepth 0 \
-not -name 'install.sh' \
-not -name '.git' \
-not -name 'README.md' \
-not -name '.gitignore' \
-not -name '.gitmodules' \
-not -name 'config' \
-not -path .
)
git -C ${DIR} submodule update --init --recursive
GLOBAL_OVERWRITE=1
while getopts "f" o; do
case "${o}" in
f)
GLOBAL_OVERWRITE=1
;;
esac
done
shift $((OPTIND-1))
for FILE in $FILES; do
FILE=$(echo $FILE | sed "s!^$DIR/!!")
NAME=$(basename $FILE)
DEST=$HOME/.$FILE
SRC=${DIR}/${FILE}
OVERWRITE=$GLOBAL_OVERWRITE
echo "Installing $SRC to $DEST ..."
if [ -e $DEST ]; then
if [ $OVERWRITE -eq 0 ]; then
read -r -p "\`$DEST' already exists. Do you want to overwrite it? [y/N] " RESPONSE
if ! [[ $RESPONSE =~ ^([yY][eE][sS]|[yY])$ ]]; then
continue
fi
fi
fi
mkdir -p $(dirname $DEST)
rm -rf ${DEST}
ln -s ${SRC} ${DEST}
echo "$DEST installed."
done