-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_cromite.sh
398 lines (235 loc) · 12.6 KB
/
setup_cromite.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
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#!/bin/bash
#setup_cromite.sh
export HISTIGNORE='*sudo -S*'
#GitHub repo redirect for latest release
cromiteurllatestredirect="https://github.com/uazo/cromite/releases/latest"
#GitHub release download repo
cromitedownloadurl="https://github.com/uazo/cromite/releases/download/"
#follow redirect to get the latest release version
cromitelatest=$(wget --max-redirect=0 $cromiteurllatestredirect 2>&1 | awk '/Location: /,// { print }' | awk '{print $2}' | awk -F "/" '{print $NF}')
create_file_cromite_desktop()
{
echo $password | sudo -S rm -rf "/usr/share/applications/cromite.desktop"
echo $password | sudo -S touch "/usr/share/applications/cromite.desktop"
echo $password | sudo -S tee -a "/usr/share/applications/cromite.desktop" >/dev/null <<EOF
#!/bin/sh
# Author: cloud coroner, cloud coroner [dot] com
# Description: Cromite is a Chromium fork based on Bromite with built-in support for adblocking and an eye for privacy.
# Executed by: user, on-demand
# Resources: /bin/sh, zenity, latest Cromite release from Uazo
[Desktop Entry]
Name=Cromite
X-MultipleArgs=false
Exec=/usr/bin/cromite/start_cromite.sh %u
Terminal=false
Type=Application
Icon=/usr/share/icons/hicolor/48x48/apps/cromite.png
Comment=Browse the World Wide Web
Keywords=Internet;WWW;Browser;Web;Explorer
Categories=GNOME;GTK;Network;WebBrowser;
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/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
StartupWMClass=Chromium-browser
EOF
#end of create_file_cromite_desktop
}
create_file_apparmor()
{
echo $password | sudo -S rm -rf "/etc/apparmor.d/usr.bin.cromite.chrome"
echo $password | sudo -S touch "/etc/apparmor.d/usr.bin.cromite.chrome"
echo $password | sudo -S tee -a "/etc/apparmor.d/usr.bin.cromite.chrome" >/dev/null <<EOF
abi <abi/4.0>,
include <tunables/global>
profile cromite /usr/bin/cromite/chrome flags=(unconfined) {
userns,
include if exists <local/chrome>
}
EOF
#end of create_file_apparmor
}
create_file_start_cromite()
{
echo $password | sudo -S rm -rf "/usr/bin/cromite/start_cromite.sh"
echo $password | sudo -S touch "/usr/bin/cromite/start_cromite.sh"
echo $password | sudo -S tee -a "/usr/bin/cromite/start_cromite.sh" >/dev/null <<EOF
#!/bin/bash
# start_cromite.sh
clear
loggedinuser=\$(who | head -n1 | awk '{print $1;}')
echo ""
echo "Cromite Update Tool started for " \$loggedinuser
if [ -f "/usr/bin/cromite/chrome" ]; then
cromiterunning=\$(ps -ef | awk '{print $8}' | grep -oP /usr/bin/cromite/chrome | head -1)
if [ "$cromiterunning" = "/usr/bin/cromite/chrome" ]; then
zenity --info --title "Cromite Update Tool" --width 500 --height 100 --text "Cromite is already open. Update check will be skipped."
setsid nohup /usr/bin/cromite/chrome \$1 &
sleep 2
else
if ping -q -c 1 -W 1 '8.8.8.8' >/dev/null; then
#GitHub repo redirect for latest release
cromiteurllatestredirect="https://github.com/uazo/cromite/releases/latest"
#GitHub release download repo
cromitedownloadurl="https://github.com/uazo/cromite/releases/download/"
cromite_inst_ver=\$(cat /usr/bin/cromite/cromite.ver)
cromitelatest=\$(wget --max-redirect=0 \$cromiteurllatestredirect 2>&1 | awk '/Location: /,// { print }' | awk '{print \$2}' | awk -F "/" '{print \$NF}')
if [[ \$cromite_inst_ver != \$cromitelatest ]]; then
if zenity --question --title "Cromite Update Tool" --width 500 --height 100 --text "Cromite has an update!\nClick Yes to proceed with the installation OR \nclick No to open Cromite without Updating."; then
password=\$(zenity --forms --title "Cromite Update Tool" --width 500 --height 100 --text "Enter your password to update Cromite." --add-password "Password:")
#download cromite tarball
echo \$password | sudo -S wget -O chrome-lin64.tar.gz \$cromitedownloadurl/\$cromitelatest/chrome-lin64.tar.gz | zenity --title "Cromite Update Tool" --width 500 --height 100 --text "Downloading Update..." --progress --pulsate --auto-close --auto-kill
#extract to install directory
echo \$password | sudo -S tar xf chrome-lin64.tar.gz -C /usr/bin/cromite --strip-components=1
echo \$password | echo \$cromitelatest | sudo -S tee /usr/bin/cromite/cromite.ver
#clean up
echo \$password | sudo -S rm -rf chrome-lin64.tar.gz
setsid nohup /usr/bin/cromite/chrome \$1 &
sleep 2
else
setsid nohup /usr/bin/cromite/chrome \$1 &
sleep 2
fi
else
setsid nohup /usr/bin/cromite/chrome \$1 &
sleep 2
fi
else
zenity --info --title "Cromite Update Tool" --width 500 --height 100 --text "No internet. Update check will be skipped."
setsid nohup /usr/bin/cromite/chrome \$1 &
sleep 2
fi
fi
else
zenity --error --title "Cromite Update Tool" --width 500 --height 100 --text "Cromite is NOT installed and cannot be updated."
fi
exit
EOF
#end of create_file_start_cromite
}
install_cromite()
{
if zenity --question --title "Cromite Install Tool" --width 500 --height 100 --text "This will install Cromite and set it as the default web browser!\nClick Yes to proceed with the installation OR \nclick No to cancel."; then
#get root password for install
password=$(zenity --forms --title "Cromite Install Tool" --width 500 --height 100 --text "Enter root password to install Cromite." --add-password "Password:")
#create install directory
echo $password | sudo -S rm -rf /usr/bin/cromite
echo $password | sudo -S mkdir /usr/bin/cromite
#chmod 400 /usr/bin/cromite
echo $password | sudo -S chown -R root:root /usr/bin/cromite
#download cromite tarball
echo $password | sudo -S wget -O chrome-lin64.tar.gz $cromitedownloadurl/$cromitelatest/chrome-lin64.tar.gz
#extract to install directory
echo $password | sudo -S tar xf chrome-lin64.tar.gz -C /usr/bin/cromite --strip-components=1
#create file with installed version for future updates
echo $password | sudo -S touch /usr/bin/cromite/cromite.ver
echo $password | echo $cromitelatest | sudo -S tee /usr/bin/cromite/cromite.ver
#create cromite startup file with update check and make executable
create_file_start_cromite
echo $password | sudo -S chmod +x /usr/bin/cromite/start_cromite.sh
#clean up
echo $password | sudo -S rm -rf chrome-lin64.tar.gz
#copy icon from downloaded release to the icon cache
echo $password | sudo -S cp /usr/bin/cromite/product_logo_48.png /usr/share/icons/hicolor/48x48/apps/cromite.png
#create cromite desktop file and set permissions
create_file_cromite_desktop
echo $password | sudo -S chmod 644 /usr/share/applications/cromite.desktop
#configure gnome to see cromite as an alternative browser and then update the database
echo $password | sudo -S update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/cromite/chrome 100
echo $password | sudo -S update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /usr/bin/cromite/chrome 100
xdg-settings set default-web-browser cromite.desktop
echo $password | sudo -S update-desktop-database
if [ "$(lsb_release -s -r)" = "24.04" ]; then
#create apparmor definition
create_file_apparmor
echo $password | sudo -S apparmor_parser -r /etc/apparmor.d/usr.bin.cromite.chrome
#end of Ubuntu 24.04 check for apparmor
fi
if [ "$(lsb_release -s -r)" = "24.04" ]; then
zenity --info --title "Cromite Install Tool 24.04" --width 500 --height 100 --text "Cromite has been Installed and set as the default Web Browser.\n\nYou will be notified of updates when you start Cromite.\n\nIf you would like to set Firefox back to default,\ngo to Settings -> Apps -> Default Apps"
#end of Ubuntu 24.04 check for install next steps
fi
if [ "$(lsb_release -s -r)" = "22.04" ]; then
zenity --info --title "Cromite Install Tool 22.04" --width 500 --height 100 --text "Cromite has been Installed and set as the default Web Browser.\n\nYou will be notified of updates when you start Cromite.\n\nIf you would like to set Firefox back to default,\ngo to Settings, Default Applications "
#end of Ubuntu 24.04 check for install next steps
fi
#end of Install verification check
fi
#end of install_cromite
}
uninstall_cromite()
{
if zenity --question --title "Cromite Uninstall Tool" --width 500 --height 100 --text "This will Uninstall Cromite and set Firefox as the default web browser!\n\nClick Yes to proceed or click No to cancel."; then
#get root password for install
password=$(zenity --forms --title "Cromite Uninstall Tool" --width 500 --height 100 --text "Enter root password to uninstall Cromite." --add-password "Password:")
#remove install directory
echo $password | sudo -S rm -rf /usr/bin/cromite
#remove downloaded cromite package
echo $password | sudo -S rm -rf chrome-lin64.tar.gz
#copy icon copied to the icon cache
echo $password | sudo -S rm -rf /usr/share/icons/hicolor/48x48/apps/cromite.png
#remove cromite desktop file
echo $password | sudo -S rm -rf /usr/share/applications/cromite.desktop
#remove cromite as an alternative browser from gnome and then update the database
echo $password | sudo -S update-alternatives --remove x-www-browser /usr/bin/cromite/chrome
echo $password | sudo -S update-alternatives --remove gnome-www-browser /usr/bin/cromite/chrome
xdg-settings set default-web-browser firefox_firefox.desktop
echo $password | sudo -S update-desktop-database
if [ "$(lsb_release -s -r)" = "24.04" ]; then
#remove apparmor definition
echo $password | sudo -S apparmor_parser -R /etc/apparmor.d/usr.bin.cromite.chrome
echo $password | sudo -S rm -rf "/etc/apparmor.d/usr.bin.cromite.chrome"
#end of Ubuntu 24.04 check for apparmor
fi
if zenity --question --title "Cromite Uninstall Tool" --width 500 --height 100 --text "Cromite has been Uninstalled.\n\nIf you would like to remove your app profile, click Yes,\nor click No to keep your Cromite settings for future installs."; then
if zenity --question --icon-name "dialog-warning" --title "Cromite Uninstall Tool" --width 500 --height 100 --text "IF YOU HAVE OTHER CHROME OR CHROMIUM BROWSERS INSTALLED\nTHIS COULD REMOVE THOSE PROFILES AS WELL\n\nClick Yes to continue or No to keep your settings for future installs."; then
rm -rf ~/.config/chromium
rm -rf ~/.gnome/apps/chrome-*
rm -rf ~/.local/share/desktop-directories/chrome-apps.directory
rm -rf ~/.local/share/applications/chrome-*
rm -rf ~/.config/menus/applications-merged/user-chrome-apps.menu
#end of profile removal final check
fi
#end of profile removal check
fi
#end of Uninstall verification check
fi
#end of uninstall_cromite
}
install_cromite_profile()
{
if zenity --question --title "Cromite Install Tool" --width 500 --height 100 --text "Would you like to configure Cromite with\nPrivate Search, additional Adblock and other settings?\n(Open the readme for more information)\n\nClick Yes to continue or No to keep default settings."; then
#ensure user profile is clear to prevent conflicts
rm -rf ~/.config/chromium
#unzip profile zip from release package into users profile
unzip cromite-home-config-chromium.zip -d ~/.config/
#end of profile removal final check
fi
#end of install_cromite_profile
}
if [ "$(lsb_release -s -i)" = "Ubuntu" ]; then
# This computer is running Ubuntu
#check CPU architecture
if [ "$(uname -p)" = "x86_64" ]; then
#zentity comes with the default Ubuntu install, but if not, install it
if [ ! -f "/usr/bin/zenity" ]; then
sudo apt install zenity
fi
setupchoice=$(zenity --forms --title "Cromite Setup Tool" --width 500 --height 100 --text "This tool helps automate the setup of Cromite from Ubuntu." --add-combo "Setup Choice:" --combo-values "Install|Uninstall")
if [ "$setupchoice" = "Install" ]; then
install_cromite
install_cromite_profile
fi
if [ "$setupchoice" = "Uninstall" ]; then
uninstall_cromite
fi
if [ "$setupchoice" = "Cancel" ]; then
exit
fi
else
zenity --error --title "Cromite Setup Tool" --width 500 --height 100 --text "This tool only works with 64 bit Intel Ubuntu computers and VMs.\n\nVMs running on Macs with Apple M series chips are not supported."
#end of CPU check
fi
else
zenity --error --title "Cromite Setup Tool" --width 500 --height 100 --text "This tool only works with Ubuntu Linux desktop computers and VMs."
#end of Ubuntu check
fi
exit