-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·82 lines (76 loc) · 2.11 KB
/
install
File metadata and controls
executable file
·82 lines (76 loc) · 2.11 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
install_type=""
dir=""
success=""
# Usage message for the install script.
function usg_msg() {
cat << ENDOFTEXT
Usage: ./install <'sys'|'user'> ['uninstall']
- sys: Installs TeXiT for every user (requires sudo).
- user: Installs TeXiT for the current user.
- uninstall: Uninstalls TeXiT for either 'sys' or 'user'.
ENDOFTEXT
}
# Checking length of arguments when running ./install.
if [ -z "$1" ]; then
usg_msg
exit 0
elif [ $# -gt 2 ]; then
echo "Error: Too many arguments." >&2
usg_msg
exit 1
else
install_type="$1"
fi
# Error checking content of first and second argument.
if [[ "$install_type" != "sys" ]] && [[ "$install_type" != "user" ]]; then
echo "Error: Invalid first argument." >&2
usg_msg
exit 1
elif [[ ! -z "$2" ]] && [[ "$2" != "uninstall" ]]; then
echo "Error: Invalid second argument." >&2
usg_msg
exit 1
fi
# Proceeding with either installing or uninstalling TeXiT.
if [[ "$2" == "uninstall" ]]; then
if [[ "$install_type" == "sys" ]]; then
sudo rm "/usr/local/bin/texit" "/usr/local/share/applications/TeXiT.desktop"\
&& success="1"
elif [[ "$install_type" == "user" ]]; then
rm "$HOME/.local/bin/texit" "$HOME/.local/share/applications/TeXiT.desktop"\
&& success="1"
fi
else
make
if [[ "$install_type" == "sys" ]]; then
dir="/usr/local"
sudo cp ./texit "$dir/bin/"\
&& sudo cp ./TeXiT.desktop "$dir/share/applications/"\
&& success="1"
elif [[ "$install_type" == "user" ]]; then
dir="$HOME/.local"
cp ./texit "$dir/bin/"\
&& cp ./TeXiT.desktop "$dir/share/applications/"\
&& success="1"
fi
make clean
fi
# Error checking if the user has entered sudo correctly.
if [ -z "$success" ]; then
if [[ "$2" == "uninstall" ]]; then
echo "Error: Failed to uninstall." >&2
exit 1
else
echo "Error: Failed to install." >&2
exit 1
fi
else
if [[ "$2" == "uninstall" ]]; then
echo "Uninstalled TeXiT."
exit 0
else
echo "TeXiT installed in $dir."
exit 0
fi
fi