-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·53 lines (31 loc) · 1.06 KB
/
install
File metadata and controls
executable file
·53 lines (31 loc) · 1.06 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
#!/usr/bin/env sh
# Installation script.
# - takes one argument: `-f` (`--force`) or `-i` (`--interactive`) which is passed to the setup script
# - idempotent
# Get directory of script, resolving symbolic links.
# (see: https://stackoverflow.com/questions/29832037)
# (see: https://stackoverflow.com/questions/10412162)
base_dir=$(
base_dir="${0}"
while [ -L "${base_dir}" ]; do
cd "${base_dir%/*}"
base_dir=$( readlink "${base_dir}" )
done
cd "${base_dir%/*}"
pwd -P
)
# SETUP
# Check for run conditions.
if [ "${1}" = "--force" -o "${1}" = "-f" ]; then
[ -r "${base_dir}"/script/setup.sh ] && source "${base_dir}"/script/setup.sh -f
elif [ "${1}" = "--interactive" -o "${1}" = "-i" ]; then
[ -r "${base_dir}"/script/setup.sh ] && source "${base_dir}"/script/setup.sh -i
else
read -r -p "This may overwrite existing files. Are you sure? (y/n) " -n 1
echo ""
if [ $( expr "${REPLY}" : '[yY]$' ) -eq 1 ]; then
[ -r "${base_dir}"/script/setup.sh ] && source "${base_dir}"/script/setup.sh -f
fi
fi
# Clean up.
unset base_dir