-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate.sh
545 lines (418 loc) · 13.2 KB
/
update.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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
#!/usr/bin/env bash
#
# This script updates all We All Code computers.
#
# bash <(curl -fsSL wac.fyi/update)
#
# or
#
# wac-update
#
VERSION="2.1.6"
GIT_BRANCH="master"
URL="https://raw.githubusercontent.com/WeAllCode/linux-update/$GIT_BRANCH"
# Set username
# USER=$(whoami)
USER='weallcode'
# MACHINE_TYPE=$(uname -m)
# Set home
HOMEDIR="/home/$USER"
# QUIET="-q"
QUIET=""
# SCRIPTDIR="/etc/init.d"
# SCRIPT="weallcode-phonehome"
# CONFDIR="/etc/init"
# CONF="$SCRIPT.conf"
# CRONDIR="/etc/cron.d"
# userrun() {
# sudo -H -u $USER bash -c "$1";
# }
output() {
printf "\n####################\n# %s\n####################\n" "$1"
notify-send --urgency=low "$1"
}
debInst() {
dpkg-query -Wf'${Status}' "$1" 2>/dev/null | grep "$QUIET" "install ok installed"
}
version() {
output "Version: $VERSION"
}
askToContinue() {
read -p "Do you want to continue? (y/N) " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo # (optional) move to a new line
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
}
# Reset ~/.bashrc settings
setBashrc() {
output "Reset '$HOMEDIR/.bashrc' settings"
wget "$QUIET" -L -O "$HOMEDIR/.bashrc" "$URL$HOMEDIR/.bashrc"
source "$HOMEDIR/.bashrc"
}
# Set custom theme to indicate update running
setCustomTheme() {
output "Set custom theme to indicate update running"
# Add custom css file to theme
grep "$QUIET" "custom.css" /usr/share/themes/elementary/gtk-3.0/gtk.css
if [ $? -eq 1 ]; then
echo '@import url("custom.css");' | sudo tee -a /usr/share/themes/elementary/gtk-3.0/gtk.css >/dev/null
fi
sudo wget "$QUIET" -L -O "/usr/share/themes/elementary/gtk-3.0/custom.css" \
"$URL/usr/share/themes/elementary/gtk-3.0/custom.css"
killall wingpanel
}
# Reset theme
unsetCustomTheme() {
output "Reset theme"
sudo rm -rf /usr/share/themes/elementary/gtk-3.0/custom.css
killall wingpanel
}
# Set sound volume to 0
setMute() {
output "Set sound volume to 0"
amixer -q -D pulse sset Master 0
}
# Cleanup files
cleanOldFiles() {
output "Cleanup files"
sudo rm -rf "/etc/apt/trusted.gpg.d/*"
# Remove old files that students might of saved
sudo rm -rf "$HOMEDIR/Documents/*"
sudo rm -rf "$HOMEDIR/Downloads/*"
sudo rm -rf "$HOMEDIR/Music/*"
sudo rm -rf "$HOMEDIR/Pictures/*"
sudo rm -rf "$HOMEDIR/Public/*"
sudo rm -rf "$HOMEDIR/Templates/*"
sudo rm -rf "$HOMEDIR/Videos/*"
}
# Update System
aptUpdate() {
output "Update System"
# sudo apt-get -qq update
sudo apt update
# sudo apt -qq autoremove -y
sudo apt autoremove -y
# sudo DEBIAN_FRONTEND=noninteractive \
# apt-get \
# -qq \
# -o Dpkg::Options::="--force-confnew" \
# -y \
# --allow-downgrades \
# --allow-remove-essential \
# --allow-change-held-packages \
# dist-upgrade
sudo DEBIAN_FRONTEND=noninteractive \
apt-get \
-o Dpkg::Options::="--force-confnew" \
-y \
--allow-downgrades \
--allow-remove-essential \
--allow-change-held-packages \
dist-upgrade
sudo apt install -y software-properties-common
}
# App Center
uninstallAppCenter() {
output "Uninstalling appcenter"
sudo apt autoremove --purge -y appcenter
}
uninstallSoftwareCenter() {
output "Uninstalling software-center"
sudo apt autoremove --purge -y software-center
}
uninstallUpdateManager() {
output "Uninstalling update-manager"
sudo apt autoremove --purge -y update-manager
}
uninstallAptitude() {
output "Uninstalling aptitude"
sudo apt autoremove --purge -y aptitude
}
uninstallAtom() {
output "Uninstalling atom"
sudo apt autoremove --purge -y atom
}
uninstallVideos() {
output "Uninstalling audience"
sudo apt autoremove --purge -y audience
}
uninstallEpiphany() {
output "Uninstalling epiphany-browser"
sudo apt autoremove --purge -y epiphany-browser
}
uninstallFirefox() {
output "Uninstalling firefox"
# Kill firefox if running
killall firefox
# Uninstall firefox
sudo apt autoremove --purge -y firefox
# Remove mozilla folder
sudo rm -rf "$HOMEDIR/.mozilla"
}
uninstallGoogleChrome() {
output "Uninstalling google-chrome"
sudo apt autoremove --purge -y \
google-chrome \
google-chrome-stable
sudo rm -rf "$HOMEDIR/.config/google-chrome*"
}
uninstallGeary() {
output "Uninstalling geary"
sudo apt autoremove --purge -y geary
}
uninstallMail() {
output "Uninstalling pantheon-mail"
sudo apt autoremove --purge -y pantheon-mail
}
uninstallMusic() {
output "Uninstalling noise"
sudo apt autoremove --purge -y noise
}
uninstallCalendar() {
output "Uninstalling maya-calendar"
sudo apt autoremove --purge -y maya-calendar
}
uninstallCode() {
output "Uninstalling io.elementary.code"
sudo apt autoremove --purge -y io.elementary.code
}
uninstallPhotos() {
output "Uninstalling pantheon-photos"
sudo apt autoremove --purge -y pantheon-photos
}
uninstallScreenshot() {
output "Uninstalling screenshot-tool"
sudo apt autoremove --purge -y screenshot-tool
}
uninstallVim() {
output "Uninstalling vim"
sudo apt autoremove --purge -y "vim-*"
}
# Cleanup
autoRemove() {
output "Cleanup"
# sudo apt-get -qq autoremove -y
sudo apt autoremove -y
# sudo apt-get -qq autoclean -y
sudo apt autoclean -y
}
installFirefox() {
output "Installing firefox"
sudo apt install -y firefox
}
installVSCode() {
output "Installing VSCode"
killall -9 code
curl -fsSL "https://packages.microsoft.com/keys/microsoft.asc" | gpg --dearmor >"$HOMEDIR/microsoft.gpg"
sudo install -o root -g root -m 644 "$HOMEDIR/microsoft.gpg" "/etc/apt/trusted.gpg.d/"
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# sudo apt-get -qq install apt-transport-https
sudo apt install -y apt-transport-https
# sudo apt-get -qq update
sudo apt update
# sudo apt-get -qq install -y code # or code-insiders
sudo apt install -y code # or code-insiders
# Cleanup
rm "$HOMEDIR/microsoft.gpg"
# Reset Code settings
output "Reset Code settings"
rm -rf "$HOMEDIR/.config/Code"
mkdir -p "$HOMEDIR/.config/Code/User/globalStorage/"
wget "$QUIET" -L -O "$HOMEDIR/.config/Code/User/settings.json" \
"$URL$HOMEDIR/.config/Code/User/settings.json"
wget "$QUIET" -L -O "$HOMEDIR/.config/Code/User/locale.json" \
"$URL$HOMEDIR/.config/Code/User/locale.json"
wget "$QUIET" -L -O "$HOMEDIR/.config/Code/User/extensions.json" \
"$URL$HOMEDIR/.config/Code/User/extensions.json"
wget "$QUIET" -L -O "$HOMEDIR/.config/Code/User/globalStorage/state.vscdb" \
"$URL$HOMEDIR/.config/Code/User/globalStorage/state.vscdb"
chown -R $USER:$USER "$HOMEDIR/.config/"
}
installVSCodium() {
output "Installing VSCodium"
wget "$QUIET" -O - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | sudo apt-key add -
echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' | sudo tee --append /etc/apt/sources.list
sudo apt update
sudo apt update --fix-missing
sudo apt install codium
}
installGit() {
output "Installing git"
sudo apt install -y git
}
installPython() {
output "Installing python3"
sudo apt install -y python3 python3-pip
}
installVim() {
output "Installing vim"
sudo apt install -y vim
}
installBacklight() {
output "Installing xbacklight"
sudo apt install -y xbacklight
}
setBrightness() {
output "Setting screen brightness to 100"
xbacklight -set 100
}
installPythonPackages() {
output "Installing Python packages"
pip3 install --upgrade --force-reinstall weallcode_robot
}
updateDock() {
output "Setting up the dock"
sudo add-apt-repository -y ppa:ricotz/docky
sudo apt-get update
sudo apt install -y plank
rm $HOMEDIR/.config/plank/dock1/launchers/*.dockitem
cd "$HOMEDIR/.config/plank/dock1/launchers/" || exit
wget "$QUIET" "$URL$HOMEDIR/.config/plank/dock1/launchers/io.elementary.files.dockitem"
wget "$QUIET" "$URL$HOMEDIR/.config/plank/dock1/launchers/code.dockitem"
wget "$QUIET" "$URL$HOMEDIR/.config/plank/dock1/launchers/firefox.dockitem"
# chown -R $USER:$USER "$HOMEDIR/.config/"
gsettings set net.launchpad.plank.dock.settings:/ zoom-percent 150
# gsettings set net.launchpad.plank.dock.settings:/ dock-items "['io.elementary.files.dockitem', 'code.dockitem', 'firefox.dockitem']"
sleep 1
# Restart dock
killall plank
cd - || exit
}
# Changing desktop background
updateBackground() {
output "Changing desktop background"
sudo wget "$QUIET" -L -O "/usr/share/backgrounds/weallcode-background.png" \
"$URL/usr/share/backgrounds/weallcode-background.png"
sudo mv "/usr/share/backgrounds/elementaryos-default" \
"/usr/share/backgrounds/elementaryos-default-bak"
sudo ln -s "/usr/share/backgrounds/weallcode-background.png" \
"/usr/share/backgrounds/elementaryos-default"
gsettings set "org.gnome.desktop.background" "picture-uri" "file:///usr/share/backgrounds/weallcode-background.png"
gsettings set "org.gnome.desktop.background" "picture-options" "zoom"
}
# Setting screensaver settings
updateScreensaver() {
output "Setting screensaver settings"
gsettings set org.gnome.desktop.screensaver lock-delay 7200
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
gsettings set org.gnome.desktop.session idle-delay 300
}
updateFilesControl() {
output "Setting files control settings"
# Disable Single Click open file/folders
gsettings set io.elementary.files.preferences single-click false
# Setting Window Controls
gsettings set org.pantheon.desktop.gala.appearance button-layout ":minimize,maximize,close"
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DialogsUseHeader': <0>, 'Gtk/EnablePrimaryPaste': <0>, 'Gtk/ShellShowsAppMenu': <0>, 'Gtk/DecorationLayout': <':minimize,maximize,close'>}"
# gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DialogsUseHeader': <0>, 'Gtk/ShellShowsAppMenu': <0>, 'Gtk/DecorationLayout': <'close:menu,maximize'>}"
}
fixRotateBug() {
sudo systemctl mask iio-sensor-proxy.service
}
openSurvey() {
# Open survey
xdg-open "https://wac.fyi/survey" &>/dev/null
}
# addElementaryTweaks() {
# output "Adding Elementary Tweaks"
# install software-properties-common
# add-apt-repository -y ppa:philip.scott/elementary-tweaks
# output "Installing elementary tweaks"
# install "elementary-tweaks"
# }
# disableGuestLogin() {
# # Disable guest login
# output "Disable guest login"
# wget "$QUIET" -L -O "/usr/share/lightdm/lightdm.conf.d/40-pantheon-greeter.conf" \
# "$URL/usr/share/lightdm/lightdm.conf.d/40-pantheon-greeter.conf"
# }
# fixDragAndDropQuirk() {
# # Fix drag and drop quirk
# output "Fix drag and drop quirk"
# wget "$QUIET" -L -O "/usr/share/X11/xorg.conf.d/60-drag-and-drop-quirk.conf" \
# "$URL/usr/share/X11/xorg.conf.d/60-drag-and-drop-quirk.conf"
# }
# installFormatScript() {
# # Install cdcformat script
# output "Install cdcformat script"
# sudo wget "$QUIET" -L -O "/usr/sbin/wac-format" \
# "$URL/usr/sbin/wac- format"
#
# sudo chmod +x "/usr/sbin/wac-format"
# }
# installPhoneHomeScript() {
# # Installing phonehome config file
# if [ ! -f "$CONFDIR/$CONF" ]; then
# output "Installing phonehome config file"
# wget "$QUIET" -L -O "$CONFDIR/$CONF" \
# "$URL$CONFDIR/$CONF"
# else
# output "Phonehome config file exists"
# fi
#
#
# # Installing phonehome script
# output "Installing phonehome script"
# wget "$QUIET" -L -O $SCRIPTDIR/$SCRIPT \
# $URL$SCRIPTDIR/$SCRIPT
# chmod +x $SCRIPTDIR/$SCRIPT
#
#
# # Installing phonehome cron
# if [ ! -f "$CRONDIR/$SCRIPT" ]; then
# output "Installing phonehome cron"
# wget "$QUIET" -L -O "$CRONDIR/$SCRIPT" \
# "$URL$CRONDIR/$SCRIPT"
# else
# output "Phonehome cron exists"
# fi
# }
# Update Script Running
# output "Update Script Running"
version
askToContinue
setBashrc
# setCustomTheme
cleanOldFiles
setMute
# uninstallAppCenter
# uninstallSoftwareCenter
# uninstallUpdateManager
# uninstallAptitude
# uninstallAtom
uninstallVideos
uninstallEpiphany
uninstallFirefox
uninstallGoogleChrome
uninstallVim
# uninstallGeary
uninstallMail
uninstallMusic
uninstallCalendar
uninstallCode
# uninstallPhotos
# uninstallScreenshot
autoRemove
installFirefox
installVSCode
# installVSCodium
installGit
installPython
installVim
installBacklight
aptUpdate
setBrightness
installPythonPackages
updateDock
updateBackground
updateScreensaver
updateFilesControl
fixRotateBug
# unsetCustomTheme
openSurvey
# Restarting in 1 minute
# output "Restarting in 1 minute"
# shutdown -r 1