-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (68 loc) · 1.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·82 lines (68 loc) · 1.6 KB
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
#!/bin/bash
function print_help {
echo "USAGE: $0 [-h] [-v] [--no-<service>]"
echo " -h: Print this help and exit"
echo " -v: Be more verbose"
echo " --no-<service>: Don't install <service>"
}
function verbose_echo {
if [ "$VERBOSE" == "y" ]; then
echo "$@"
fi
}
CONFIG_BASE=~/.files/configs
DONT_INSTALL=()
VERBOSE=n
INSTALL_NAMES=()
INSTALL_SRC=()
INSTALL_DEST=()
while IFS=$'\t' read -r -a line; do
INSTALL_NAMES+=(${line[0]})
INSTALL_SRC+=(${line[1]})
INSTALL_DEST+=(${line[2]})
done < ./configs/targets.tsv
while [ "$#" != "0" ]; do
case $1 in
--no-*)
DONT_INSTALL+=(${1:5})
;;
-v)
VERBOSE=y
;;
-?)
print_help
exit 0
;;
*)
echo "Invalid argument: $1"
print_help
exit 1
;;
esac
shift
done
verbose_echo Verbose is on
verbose_echo Not installing "(${DONT_INSTALL[*]})"
for ((i = 0; i < ${#INSTALL_NAMES[*]}; i++)); do
name=${INSTALL_NAMES[$i]}
src=${INSTALL_SRC[$i]}
dest=${INSTALL_DEST[$i]}
dest=${dest/#\~/$HOME}
verbose_echo "---- $name ($src) ---"
if [[ ${DONT_INSTALL[*]} =~ (^|[[:space:]])"$name"($|[[:space:]]) ]]; then
verbose_echo Skipping...
verbose_echo
continue
fi
if [ "$VERBOSE" == "y" ]; then
mkdir -vp `dirname $dest`
else
mkdir -p `dirname $dest`
fi
if [ "$VERBOSE" == "y" ]; then
ln -svfT "$CONFIG_BASE/$src" "$dest"
else
ln -sfT "$CONFIG_BASE/$src" "$dest"
fi
verbose_echo
done