-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·64 lines (51 loc) · 1.45 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
#!/bin/env bash
name=${0##*/}
CFG_DIR="$HOME/.local/share/Steam/SteamApps/common/Team Fortress 2/tf/cfg"
function print_help() {
echo "usage: $name [options]
optional args:
-p|--pretend print what install will do without doing it.
-c|--cfgdir use an alternate cfg dir. Default is $CFG_DIR
-h|--help print this help."
}
pretend=0
OPTS=$(getopt -o phc: --long pretend,help,cfgdir: -n "$name" -- "$@")
if [ $? != 0 ]; then echo "option error" >&2; exit 1; fi
eval set -- "$OPTS"
while true; do
case "$1" in
-p|--pretend)
pretend=1
shift;;
-c|--cfgdir)
CFG_DIR="$2"
shift 2;;
-h|--help)
print_help
exit 0
;;
--)
shift; break;;
*)
echo "Internal error!"; exit 1;;
esac
done
pushd $(dirname $0) &> /dev/null
for cfg in $(ls); do
if [ ! $cfg == "README.rst" -a ! $cfg == "install.sh" -a ! $cfg == "LICENSE" ]; then
target="$CFG_DIR/$cfg"
if [[ $pretend -eq 1 ]]; then
echo "Would set $cfg to $target"
else
# Make a .bak of a file or dir
if [ ! -h "$target" ]; then
if [ -d "$target" -o -f "$target" ]; then
mv "$target" "${target}.bak"
fi
fi
echo "Setting $cfg to $target"
ln -sf "$PWD/$cfg" "$target"
fi
fi
done
popd &> /dev/null