forked from ExodusMovement/exodus-linux-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexodus-installer.sh
executable file
·161 lines (132 loc) · 3.28 KB
/
exodus-installer.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
# https://www.gnu.org/software/bash/manual/bash.html
INSTALLER_VERSION=1.0.2
exodus_download_url() {
echo 'https://dl.dropboxusercontent.com/u/173974/exodus/release/exodus_linux_'$1'.tar.xz'
}
exodus_download_target() {
echo $HOME'/Downloads/exodus_linux_'$1'.tar.xz'
}
exodus_download() {
if [ -e $2 ]; then
echo $2' already exists, overwrite it?'
select yn in 'Yes' 'No'; do
case $yn in
'Yes' )
wget -v -o $2 $1
break
;;
'No' )
break
;;
esac
done
fi
}
exodus_install() {
# extract files & create link
xz -dkfc $1 | tar -x -C /
ln -s -f /opt/exodus/Exodus /usr/bin/Exodus
# register exodus://
update-desktop-database > /dev/null 2>&1
# update icons
gtk-update-icon-cache /usr/share/icons/hicolor -f > /dev/null 2>&1
}
exodus_is_installed() {
which Exodus > /dev/null 2>&1
}
exodus_uninstall() {
# remove app files
rm -f /usr/bin/Exodus
rm -rf /opt/exodus
rm -f /usr/share/applications/Exodus.desktop
find /usr/share/icons/hicolor/ -type f -name *Exodus.png -delete
# drop exodus://
update-desktop-database > /dev/null 2>&1
# update icons
gtk-update-icon-cache /usr/share/icons/hicolor -f > /dev/null 2>&1
}
exodus_installer() {
if [ $# -lt 1 ]; then
$0 --help
return 0
fi
local COMMAND
COMMAND=$1
shift
case $COMMAND in
'help' | '--help' )
cat << EOF
Exodus installer v$INSTALLER_VERSION
Usage:
$0 --help Print this message
$0 install <version|file> Install Exodus from file or download and install <version>
$0 check Check that Exodus is installed and print installed version
$0 uninstall Remove Exodus
Example:
$0 install ~/Downloads/exodus_linux_1.4.0.tar.xz Install Exodus 1.4.0 from file
$0 install 1.4.0 Download and install Exodus 1.4.0
EOF
;;
'install' | 'i' )
if [ $# -ne 1 ]; then
>&2 $0 --help
return 127
fi
exodus_is_installed
if [ $? -eq 0 ]; then
>&2 echo 'Exodus already installed.'
return 1
fi
local EXODUS_PKG
if [[ $# -eq 1 && -f $1 ]]; then
EXODUS_PKG=$1
else
EXODUS_PKG=`exodus_download_target $1`
exodus_download `exodus_download_url $1` $EXODUS_PKG
fi
xz -t $EXODUS_PKG
if [ $? -ne 0 ]; then
return 1
fi
if [ $EUID -ne 0 ]; then
>&2 echo 'Root privileges required...'
>&2 echo ' sudo' $0 'install' $@
return 1
fi
exodus_install $EXODUS_PKG
return $?
;;
'check' )
if [ $# -ne 0 ]; then
>&2 $0 --help
return 127
fi
exodus_is_installed
if [ $? -eq 1 ]; then
echo 'Exodus is not installed.'
else
echo 'Exodus is installed. Version: '`Exodus --version`
fi
;;
'uninstall' )
if [ $# -ne 0 ]; then
>&2 $0 --help
return 127
fi
if [ $EUID -ne 0 ]; then
>&2 echo 'Root privileges required...'
>&2 echo ' sudo' $0 'install' $@
return 1
fi
exodus_uninstall
return $?
;;
* )
>&2 $0 --help
return 127
;;
esac
}
# pass arguments to main function
exodus_installer $@