-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTALL.sh
69 lines (63 loc) · 1.62 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
65
66
67
68
69
#!/bin/bash
usage () {
cat <<- _EOF_
tuxtype-make-wordlist installation script: usage: INSTALL.sh [-h|-g|-l]
-h, --help -> Display this help and exit
-g, --global -> Install globally, requires super-user privileges
-l, --local -> Install locally, doesn't require elevated privileges
_EOF_
}
check_PATH () {
# checks whether or not ~/.local/bin
# is in the PATH variable or not
echo $PATH | grep --silent $HOME/\.local/bin
if [ $? -ne 0 ]; then
{ echo -n "export PATH='"
echo -n $HOME/.local/bin: ;
echo $PATH\' ;
} >> ~/.profile
source ~/.profile
fi
}
local_install () {
# will reside in ~/.local/bin
check_PATH
mkdir -p ~/.local/bin
cp -a $(dirname $0)/makeWordList.sh ~/.local/bin/tuxtype-make-wordlist
echo "Completed local installation successfully."
}
global_install () {
# will reside in /usr/local/bin
# requires superuser privileges
if [ $(id -u) -eq 0 ]; then
cp $(dirname $0)/makeWordList.sh /usr/local/bin/tuxtype-make-wordlist
chmod 755 /usr/local/bin/tuxtype-make-wordlist
chown root: /usr/local/bin/tuxtype-make-wordlist
[[ $? -eq 0 ]] && echo "Global Installation successful."
else
echo "Error: Requires Super User Privileges for global installation."
echo "Try local installation instead, or use sudo, or ask your sysadmin."
echo "Exiting."
exit 1
fi
}
if [[ -z "$1" ]]; then
usage
exit
fi
while [[ -n "$1" ]]; do
case $1 in
-h | --help ) usage
exit
;;
-g | --global ) global_install
exit
;;
-l | --local ) local_install
exit
;;
* ) usage
exit 1
esac
shift
done