/
get-waterfox
executable file
·284 lines (269 loc) · 12.3 KB
/
get-waterfox
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#! /bin/bash
version="1.9"
#Check if Parameters are set
if [ "$1" = "" ] || [ "$1" = "-h" ]; then
echo "Welcome to get-waterfox $version !"
echo ""
echo "Usage:"
echo ""
echo "Create Waterfox dir:"
echo "# get-waterfox init >>> First init to create env >>> -I"
echo ""
echo "Select Waterfox target:"
echo "$ get-waterfox target [classic] [G4] >>> Select your Waterfox target >>> -t"
echo "$ get-waterfox showtarget >>> Check your Waterfox target >>> -s"
echo "(Target classic is default)"
echo ""
echo "First installation"
echo "$ get-waterfox download >>> Download the Waterfox Tarball >>> -d"
echo "# get-waterfox install >>> Install the Waterfox Tarball & create all links etc >>> -i"
echo ""
echo "General commands"
echo "# get-waterfox update >>> Update Waterfox >>> -u"
echo "$ get-waterfox cleanup >>> Delete old waterfox tarball >>> -C"
echo "$ get-waterfox checkupdate >>> Shows if a Waterfox update is available >>> -c"
echo "$ get-waterfox testrun >>> Test functionality before installation >>> -T"
echo "$ get-waterfox version >>> Print version of get-waterfox >>> -v"
echo ""
echo "Remove Waterfox"
echo "# get-waterfox remove >>> Remove Waterfox complete >>> -r"
echo ""
echo "Use '-h' to show this help"
echo "Please run the commands this way: init; download; install"
echo "For future updates just run: sudo get-waterfox -u"
exit
fi
#Init Waterfox
if [ "$1" = "init" ] || [ "$1" = "-I" ]; then
if [ "$EUID" != "0" ]; then
echo "[INFO] Please run as root"
exit
fi
echo "[INIT] Creating working folder /usr/share/waterfox"
mkdir /usr/share/waterfox
echo "[INIT] Creating data folder /usr/share/waterfox"
mkdir /usr/share/waterfox-data
echo "[INIT] Alter rights in working & data dir"
chmod 777 /usr/share/waterfox/ --recursive
chmod 777 /usr/share/waterfox-data/ --recursive
echo "[INIT] Creating localversion file"
touch /usr/share/waterfox-data/localversion
echo "[INIT] Alter rights for localversion file"
chmod 777 /usr/share/waterfox-data/localversion
echo "[INIT] Creating target file"
touch /usr/share/waterfox-data/target
echo "[INIT] Alter rights for target file"
chmod 777 /usr/share/waterfox-data/target
echo "[INIT] Set default target to classic"
echo "classic" > /usr/share/waterfox-data/target
exit
fi
#Target Waterfox
if [ "$1" = "target" ] || [ "$1" = "-t" ]; then
if [ "$2" = "classic" ] || [ "$2" = "G4" ]; then
echo "$2" > /usr/share/waterfox-data/target
echo "[INFO] Set target to $2"
exit
else
echo "[WARN] Invalid target!"
echo "[INFO] Please set a valid target!"
echo "[INFO] For Waterfox G4 use UPPERCASE G!"
exit
fi
fi
#Show Target Waterfox
if [ "$1" = "showtarget" ] || [ "$1" = "-s" ]; then
echo "$(cat /usr/share/waterfox-data/target)"
exit
fi
#Download Waterfox
if [ "$1" = "download" ] || [ "$1" = "-d" ]; then
if [ -e "/usr/share/waterfox-data/waterfox.tar.bz2" ]; then
echo "[CLEAN] Cleaning up ..."
rm /usr/share/waterfox-data/waterfox.tar.bz2
else
echo "[INFO] Cache is already clean!"
fi
target="$(cat /usr/share/waterfox-data/target)"
echo "[INFO] Downloading $(cat /usr/share/waterfox-data/target) Waterfox from waterfoxproject.org to /usr/share/waterfox-data"
#remoteversion="$(curl https://www.waterfox.net/download/ |grep -Eo "(https)://[a-zA-Z0-9./?=_-]*" |sort |grep linux64 |uniq |grep $(cat /usr/share/waterfox-data/target) )"
remoteversion="$(curl https://cdn.waterfox.net/releases/linux64/installer/ |grep $(cat /usr/share/waterfox-data/target) |tail --lines 1 |awk '{print $2}' |cut -c7-9999 |egrep -o '^[^\"]+')"
echo "[INFO] Please stand by ..."
#echo "[DEBUG] Remoteversion String: $remoteversion"
wget https://cdn.waterfox.net/releases/linux64/installer/$remoteversion -O /usr/share/waterfox-data/waterfox.tar.bz2
echo "[INFO] Download ready!"
echo "[INFO] Setup localversion file"
echo "[INFO] Updating localversion file"
echo "$remoteversion" > /usr/share/waterfox-data/localversion
echo "[ OK ] Now execute: sudo get-waterfox install"
exit
fi
#Install Waterfox
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
if [ "$EUID" != "0" ]; then
echo "[INFO] Please run as root"
exit
fi
echo "[INSTALLING] $(ls /usr/share/waterfox-data/ |grep .tar)"
echo "[INFO] Reading target"
target="$(cat /usr/share/waterfox-data/target)"
echo "[EXTRACTING] Please wait ..."
tar -xf /usr/share/waterfox-data/waterfox.tar.bz2 -C /usr/share/waterfox/
echo "[LINKING] Creating symlinks ..."
if [ "$target" = "G4" ]; then
ln -s /usr/share/waterfox/waterfox/waterfox /bin/waterfox
fi
if [ "$target" = "classic" ]; then
ln -s /usr/share/waterfox/waterfox-classic/waterfox /bin/waterfox
fi
echo "[LINKING] Creating starter in /usr/share/applications"
touch /usr/share/applications/waterfox.desktop
echo "[Desktop Entry]" > /usr/share/applications/waterfox.desktop
echo "Version=1.0" >> /usr/share/applications/waterfox.desktop
echo "Encoding=UTF-8" >> /usr/share/applications/waterfox.desktop
echo "Name=Waterfox" >> /usr/share/applications/waterfox.desktop
echo "Comment=Browse the World Wide Web" >> /usr/share/applications/waterfox.desktop
echo "GenericName=Web Browser" >> /usr/share/applications/waterfox.desktop
echo "Keywords=Internet;WWW;Browser;Web;Explorer" >> /usr/share/applications/waterfox.desktop
echo "Exec=waterfox %u" >> /usr/share/applications/waterfox.desktop
echo "Terminal=false" >> /usr/share/applications/waterfox.desktop
echo "X-MuiltpleArgs=false" >> /usr/share/applications/waterfox.desktop
echo "Type=Application" >> /usr/share/applications/waterfox.desktop
if [ "$target" = "G4" ]; then
ln -s /usr/share/waterfox/waterfox/waterfox /bin/waterfox
echo "Icon=/usr/share/waterfox/waterfox/browser/chrome/icons/default/default128.png" >> /usr/share/applications/waterfox.desktop
fi
if [ "$target" = "classic" ]; then
ln -s /usr/share/waterfox/waterfox-classic/waterfox /bin/waterfox
echo "Icon=/usr/share/waterfox/waterfox-classic/browser/chrome/icons/default/default128.png" >> /usr/share/applications/waterfox.desktop
fi
echo "Categories=Network;WebBrowser;" >> /usr/share/applications/waterfox.desktop
echo "MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/chrome;video/webm;application/x-xpinstall;" >> /usr/share/applications/waterfox.desktop
echo "StartupWMClass=Waterfox" >> /usr/share/applications/waterfox.desktop
echo "StartupNotify=true" >> /usr/share/applications/waterfox.desktop
echo "Actions=NewWindow;NewPrivateWindow;" >> /usr/share/applications/waterfox.desktop
echo "" >> /usr/share/applications/waterfox.desktop
echo "[Desktop Action NewWindow]" >> /usr/share/applications/waterfox.desktop
echo "Name=Open a New Window" >> /usr/share/applications/waterfox.desktop
echo "Exec=waterfox -new-window" >> /usr/share/applications/waterfox.desktop
echo "" >> /usr/share/applications/waterfox.desktop
echo "[Desktop Action NewPrivateWindow]" >> /usr/share/applications/waterfox.desktop
echo "Name=Open a New Private Window" >> /usr/share/applications/waterfox.desktop
echo "Exec=waterfox -private-window" >> /usr/share/applications/waterfox.desktop
echo ""
echo ""
echo "[INFO] Installation done!"
echo "[WARN] A cache copy of the Waterfox tarball still exist!"
echo "[INFO] You can clean the cache now by running: 'sudo get-waterfox cleanup'"
echo "[INFO] Otherweise you can allways use 'get-waterfox download' to overwrite the old cache copy with a new one."
exit
fi
#Remove Waterfox
if [ "$1" = "remove" ] || [ "$1" = "-r" ]; then
if [ "$EUID" != "0" ]; then
echo "[INFO] Please run as root"
exit
fi
echo "[ALERT] Removing folder /usr/share/waterfox"
rm -rf /usr/share/waterfox
echo "[ALERT] Removing folder /usr/share/waterfox-data"
rm -rf /usr/share/waterfox-data
echo "[ALERT] Removing starter from /usr/share/applications"
rm /usr/share/applications/waterfox.desktop
echo "[ALERT] Removing symlinks"
unlink /bin/waterfox
echo "[READY] Waterfox was completely removed from your System!"
exit
fi
#Update Waterfox
if [ "$1" = "update" ] || [ "$1" = "-u" ]; then
if [ "$EUID" != "0" ]; then
echo "[INFO] Please run as root"
exit
fi
echo "[UPDATE] Waterfox $(cat /usr/share/waterfox-data/target) update started!"
echo "[INFO] Searching for new version ..."
echo "[INFO] Checking localversion file ..."
localversion="$(cat /usr/share/waterfox-data/localversion)"
echo "[INFO] Checking remote version(s) ..."
#remoteversion="$(curl https://www.waterfox.net/download/ |grep -Eo "(https)://[a-zA-Z0-9./?=_-]*" |sort |grep linux64 |uniq |grep $(cat /usr/share/waterfox-data/target) )"
remoteversion="$(curl https://cdn.waterfox.net/releases/linux64/installer/ |grep $(cat /usr/share/waterfox-data/target) |tail --lines 1 |awk '{print $2}' |cut -c7-9999 |egrep -o '^[^\"]+')"
if [ "$localversion" == "$remoteversion" ]; then
echo "[INFO] The latest version is already installed!"
exit
fi
echo "[INFO] New version found!"
echo "[PREP] Preparing /usr/share/waterfox ..."
rm -rf /usr/share/waterfox/*
echo "[PREP] Preparing /usr/share/waterfox-data ..."
rm -rf /usr/share/waterfox-data/waterfox.tar.bz2
echo "[INFO] Downloading current Waterfox from waterfoxproject.org to /usr/share/waterfox-data"
echo "[INFO] Please stand by ..."
wget https://cdn.waterfox.net/releases/linux64/installer/$remoteversion -O /usr/share/waterfox-data/waterfox.tar.bz2
echo "[ OK ] Download ready!"
echo "[EXTRACTING] Please wait ..."
tar -xf /usr/share/waterfox-data/waterfox.tar.bz2 -C /usr/share/waterfox/
echo "[INFO] Updating localversion file"
echo "$remoteversion" > /usr/share/waterfox-data/localversion
echo "[DONE] Update ready!"
echo "[WARN] A cache copy of the Waterfox tarball still exist!"
echo "[INFO] You can clean the cache now by running: 'sudo get-waterfox cleanup'"
echo "[INFO] Otherweise you can allways use 'get-waterfox download' to overwrite the old cache copy with a new one."
exit
fi
#Cleanup Waterfox
if [ "$1" = "cleanup" ] || [ "$1" = "-C" ]; then
if [ -e "/usr/share/waterfox/waterfox.tar.bz2" ]; then
echo "[CLEAN] Cleaning up ..."
rm /usr/share/waterfox-data/waterfox.tar.bz2
else
echo "[INFO] Cache is already clean!"
fi
echo "[ OK ] Done!"
exit
fi
#Checkupdate
if [ "$1" = "checkupdate" ] || [ "$1" = "-c" ]; then
echo "[INFO] Searching for a new version of Waterfox $(cat /usr/share/waterfox-data/target) ..."
echo "[INFO] Checking localversion file ..."
localversion="$(cat /usr/share/waterfox-data/localversion)"
echo "[INFO] Checking remote version(s) ..."
#remoteversion="$(curl https://www.waterfox.net/download/ |grep -Eo "(https)://[a-zA-Z0-9./?=_-]*" |sort |grep linux64 |uniq |grep $(cat /usr/share/waterfox-data/target) )"
remoteversion="$(curl https://cdn.waterfox.net/releases/linux64/installer/ |grep $(cat /usr/share/waterfox-data/target) |tail --lines 1 |awk '{print $2}' |cut -c7-9999 |egrep -o '^[^\"]+')"
if [ "$localversion" == "$remoteversion" ]; then
echo "[INFO] The latest version is already installed!"
exit
fi
echo "[INFO] New version found!"
echo "[INFO] You can update your Waterfox by running: sudo get-waterfox update"
exit
fi
#Testrun
if [ "$1" = "testrun" ] || [ "$1" = "-T" ]; then
echo "[INFO] Executing Pre Installation Testrun ..."
echo "[ENV]"
echo "[INFO] get-waterfox $version"
echo "[INFO] Target: $(cat /usr/share/waterfox-data/target)"
echo "[INFO] Source: $(cat /usr/share/waterfox-data/localversion)"
echo "[INFO] Time: $(date)"
echo "[INFO] Machine: $(uname -a)"
echo "[INFO] Path: /usr/share/waterfox-data/"
echo "[INFO] Creating testing dir"
mkdir /usr/share/waterfox-data/test
echo "[EXTRACTING] Please wait ..."
tar -xvf /usr/share/waterfox-data/waterfox.tar.bz2 -C /usr/share/waterfox-data/test/
echo "[INFO] Running Waterfox ..."
/usr/share/waterfox-data/test/waterfox-$(cat /usr/share/waterfox-data/target)/waterfox
echo "[INFO] Removing testing dir ..."
rm -rf /usr/share/waterfox-data/test/
echo "[INFO] Testing ready."
echo "[INFO] If Waterfox was working correctly its safe to execute $ sudo get-waterfox install"
exit
fi
#Version
if [ "$1" = "version" ] || [ "$1" = "-v" ]; then
echo "get-waterfox $version"
exit
fi
#Unkown Input
echo "Can't understand, please use -h for help"