-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstaller
executable file
·56 lines (52 loc) · 1.29 KB
/
installer
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
#!/bin/sh -e
#
# (Un)installation script for the Makefile to call; the script is a bit complex
# to put in the Makefile. It tries to do stuff as a normal user and only falls
# back to root if necessary.
if test -z "$MAKEFILE"; then
echo >&2 'Only run this command through make install'
exit 1
fi
ask_to_proceed() {
while :; do
printf 'Do you wish to proceed? (yes/no) '
read -r answer || exit 0
case "$answer" in
[Yy]*) return 0 ;;
[Nn]*) exit 0 ;;
esac
done
}
do_or_sudo() {
( exec "$@" ) || (
: Trying again as super user
exec sudo "$@"
)
}
case "$1" in
install)
echo
echo "Installing executable to $EXE_INSTALL"
echo " Installing game data to $DATA_INSTALL"
echo " Installing manual to $MAN_INSTALL"
ask_to_proceed
set -x
do_or_sudo mkdir -p "$(dirname "$EXE_INSTALL")"
do_or_sudo cp "$EXE" "$EXE_INSTALL"
do_or_sudo mkdir -p "$DATA_INSTALL"
do_or_sudo cp -fr "$DATA_DIR"/* LICENSE "$DATA_INSTALL"
do_or_sudo mkdir -p "$(dirname "$MAN_INSTALL")"
do_or_sudo cp -f "$MAN_PAGE" "$MAN_INSTALL"
;;
uninstall)
echo
echo "Removing executable at $EXE_INSTALL"
echo " Removing game data at $DATA_INSTALL"
echo " Removing manual at $MAN_INSTALL"
ask_to_proceed
set -x
do_or_sudo rm -f "$EXE_INSTALL"
do_or_sudo rm -rf "$DATA_INSTALL"
do_or_sudo rm -f "$MAN_INSTALL"
;;
esac