-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraise-or-run-setup
More file actions
executable file
·54 lines (44 loc) · 955 Bytes
/
Copy pathraise-or-run-setup
File metadata and controls
executable file
·54 lines (44 loc) · 955 Bytes
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
#!/bin/bash
# User setup script.
# (C) Mark Blakeney, Aug 2016.
PROG="$(basename $0)"
NAME=${PROG%-*}
BINDIR="/usr/bin"
DOCDIR="/usr/share/doc/$NAME"
usage() {
echo "Usage:"
echo "As root: sudo $PROG install|uninstall"
echo
echo "(-d option sets DESTDIR for install/uninstall)"
exit 1
}
# Process command line options
DESTDIR=""
while getopts d: c; do
case $c in
d) DESTDIR="$OPTARG";;
\?) usage;;
esac
done
shift $((OPTIND - 1))
if [[ $# -ne 1 ]]; then
usage
fi
cmd="$1"
if [[ $cmd == install || $cmd == uninstall ]]; then
DESTDIR="${DESTDIR%%+(/)}"
if [[ -z $DESTDIR && $(id -un) != root ]]; then
echo "Install or uninstall must be run as sudo/root."
exit 1
fi
if [[ $cmd == install ]]; then
install -CDv -m 755 -t $DESTDIR$BINDIR $NAME
install -CDv -m 644 -t $DESTDIR$DOCDIR README.md
else
rm -rfv $DESTDIR$DOCDIR
rm -rfv $DESTDIR$BINDIR/$NAME
fi
else
usage
fi
exit 0