forked from WeAllCode/linux-update
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
464 lines (321 loc) · 11.5 KB
/
update.sh
File metadata and controls
464 lines (321 loc) · 11.5 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
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
URL="https://raw.githubusercontent.com/weallcode/linux-update/master"
USERNAME=weallcode
HOMEDIR="/home/weallcode"
SCRIPTDIR="/etc/init.d"
SCRIPT="weallcode-phonehome"
CONFDIR="/etc/init"
CONF="$SCRIPT.conf"
CRONDIR="/etc/cron.d"
MACHINE_TYPE=`uname -m`
userrun() {
sudo -H -u weallcode bash -c "$1";
}
output() {
echo "\n\n####################\n# $1\n####################\n\n";
userrun "notify-send --urgency=low '$1'";
}
debInst() {
dpkg-query -Wf'${Status}' "$1" 2>/dev/null | grep -q "install ok installed"
}
install() {
debInst "$1"
if [ $? -eq 1 ]; then
apt install --force-yes -y "$1"
fi
}
uninstall() {
if debInst "$1"; then
if [ -x "$2" ]; then
apt-get remove -y "$2"
else
apt-get remove -y "$1"
fi
fi
}
if ! getent passwd $USERNAME > /dev/null 2>&1; then
echo "User weallcode does not exist, aborting update script"
exit -1
fi
# Update Script Running
output "Update Script Running"
echo ".panel,.panel.maximized,.panel.translucent{background-color:red;}" >> /usr/share/themes/elementary/gtk-3.0/apps.css
killall wingpanel
# Cleanup files
output "Cleanup files"
rm -rf /etc/apt/trusted.gpg.d/*
# Remove old files that students might of saved
rm -rf $HOMEDIR/Documents/*
rm -rf $HOMEDIR/Downloads/*
rm -rf $HOMEDIR/Music/*
rm -rf $HOMEDIR/Pictures/*
rm -rf $HOMEDIR/Public/*
rm -rf $HOMEDIR/Templates/*
rm -rf $HOMEDIR/Videos/*
# ---
# # Adding Google to package manager
# output "Adding Google to package manager"
# wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
# Remove Google apt source
output "Remove Google apt source"
rm -rf /etc/apt/sources.list.d/google-chrome.list*
# wget -qLO /etc/apt/sources.list.d/google-chrome.list \
# "$URL/etc/apt/sources.list.d/google-chrome.list"
# ---
# Adding VS Code to package manager
output "Adding VS Code to package manager"
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# ---
# # Removing Elementary Tweaks from package manager
# output "Removing Elementary Tweaks from package manager"
install software-properties-common
add-apt-repository -y ppa:philip.scott/elementary-tweaks
# add-apt-repository -r -y ppa:philip.scott/elementary-tweaks
# ---
# Uninstalling unused packages
output "Uninstalling unused packages"
output "Uninstall activity log"
uninstall activity-log-manager-common
uninstall activity-log-manager-control-center
output "Uninstall App Center"
command -v zeitgeist-daemon &> /dev/null
if [ $? -eq 0 ]; then
zeitgeist-daemon --quit
fi
uninstall appcenter
uninstall software-center
uninstall update-manager
uninstall zeitgeist
uninstall zeitgeist-core
uninstall zeitgeist-datahub
rm -rf {/root,/home/*}/.local/share/zeitgeist
output "Uninstall aptitude"
uninstall "aptitude"
output "Uninstall Atom"
uninstall "atom"
output "Uninstall Audience"
uninstall "audience"
output "Uninstall deja-dup"
uninstall "deja-dup"
# output "Uninstall Elementary Tweaks"
# uninstall "elementary-tweaks"
output "Uninstall Empathy"
uninstall "empathy-*" "^empathy-.*"
output "Uninstall Epiphany"
uninstall "epiphany-*" "^epiphany-.*"
# output "Uninstall Firefox"
# uninstall "firefox*" "^firefox.*"
output "Uninstall Geary"
uninstall "geary"
output "Uninstall Google"
uninstall "google-*" "^google-.*"
rm -rf $HOMEDIR/.config/google-chrome*
output "Uninstall Gnome Online Accounts"
uninstall "gnome-online-accounts"
uninstall "indicator-messages"
output "Uninstall Midori"
uninstall "midori-granite"
rm -rf $HOMEDIR/.config/midori
output "Uninstall Mode Manager"
uninstall "modemmanager"
output "Uninstall Noise"
uninstall "noise"
output "Uninstall Pantheon Mail"
uninstall "pantheon-mail"
output "Uninstall Pantheon Photos"
uninstall "pantheon-photos*" "^pantheon-photos.*"
output "Uninstall Scatch Text Editor"
uninstall "scratch-text-editor"
output "Uninstall Screenshot Tool"
uninstall "screenshot-tool"
output "Uninstall Simple Scan"
uninstall "simple-scan"
# ---
# Upgrading system
output "Upgrading system"
apt update
apt dist-upgrade -y
# Cleanup
output "Cleanup"
apt-get autoremove -y
apt-get autoclean -y
# ---
# Installing programs
output "Installing programs"
output "Installing Firefox"
install "firefox"
output "Installing Visual Studio Code"
install "code"
output "Installing gedit"
install "gedit"
output "Installing git"
install "git"
# output "Installing Google Chrome Stable"
# install "google-chrome-stable"
output "Installing vim"
install "vim"
output "Installing xbacklight"
install "xbacklight"
output "Installing elementary tweaks"
install "elementary-tweaks"
# ---
# Reset ~/.bashrc settings
output "Reset ~/.bashrc settings"
wget -qLO "$HOMEDIR/.bashrc" \
"$URL$HOMEDIR/.bashrc"
# ---
# Reset Code settings
output "Reset Code settings"
rm -rf "$HOMEDIR/.config/Code/User/"
mkdir -p "$HOMEDIR/.config/Code/User/"
wget -qLO "$HOMEDIR/.config/Code/User/settings.json" \
"$URL$HOMEDIR/.config/Code/User/settings.json"
# ---
# Setting screen brightness to 100
output "Setting screen brightness to 100"
xbacklight -set 100
# ---
# Installing Finch files
output "Installing Finch files"
cd /tmp/
wget -O "Bird.tar.gz" "https://www.dropbox.com/s/5ftpl16rbevg4fq/BirdBrainRobotServerLinux.tar.gz?dl=1"
tar -xvzf Bird.tar.gz
cd BirdBrainRobotServerLinux
sudo ./Configure
# ---
# Configuring Google Chrome
# output "Configuring Google Chrome"
# wget -qLO /opt/google/chrome/default_apps/external_extensions.json \
# "$URL/opt/google/chrome/default_apps/external_extensions.json"
#
# userrun 'google-chrome-stable --no-first-run > /dev/null 2>&1 &'
# userrun 'sleep 10'
# userrun 'killall chrome'
# userrun 'sleep 5'
#
# # Disabling Google's Custom Frame
# if grep -q "custom_chrome_frame" $HOMEDIR/.config/google-chrome/Default/Preferences; then
# # Already in the file, change true to false
# sed -i 's/"custom_chrome_frame":true/"custom_chrome_frame":false/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# else
# # Not in the file, add it to the file before "window_placement"
# sed -i 's/"window_placement"/"custom_chrome_frame":false,"window_placement"/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# fi
#
# # Clear browser history
# if grep -q "clear_lso_data_enabled" $HOMEDIR/.config/google-chrome/Default/Preferences; then
# # Already in the file, change true to false
# sed -i 's/"clear_lso_data_enabled":false/"clear_lso_data_enabled":true/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# else
# # Not in the file, add it to the file before "window_placement"
# sed -i 's/"window_placement"/"clear_lso_data_enabled":true,"window_placement"/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# fi
#
# # Enable pepper flash in browser
# if grep -q "pepper_flash_settings_enabled" $HOMEDIR/.config/google-chrome/Default/Preferences; then
# # Already in the file, change true to false
# sed -i 's/"pepper_flash_settings_enabled":false/"pepper_flash_settings_enabled":true/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# else
# # Not in the file, add it to the file before "window_placement"
# sed -i 's/"window_placement"/"pepper_flash_settings_enabled":true,"window_placement"/' \
# $HOMEDIR/.config/google-chrome/Default/Preferences
# fi
#
# # Fixing Chrome Keyring issue
# output "Fixing Chrome Keyring issue"
# mv /usr/bin/gnome-keyring-daemon /usr/bin/gnome-keyring-daemon-bak
# killall gnome-keyring-daemon
# ---
# Setting up the dock
output "Setting up the dock"
rm $HOMEDIR/.config/plank/dock1/launchers/*.dockitem
wget -qLO "$HOMEDIR/.config/plank/dock1/launchers/pantheon-files.dockitem" \
"$URL$HOMEDIR/.config/plank/dock1/launchers/pantheon-files.dockitem"
wget -qLO "$HOMEDIR/.config/plank/dock1/launchers/code.dockitem" \
"$URL$HOMEDIR/.config/plank/dock1/launchers/code.dockitem"
# wget -qLO "$HOMEDIR/.config/plank/dock1/launchers/google-chrome.dockitem" \
# "$URL$HOMEDIR/.config/plank/dock1/launchers/google-chrome.dockitem"
wget -qLO "$HOMEDIR/.config/plank/dock1/launchers/firefox.dockitem" \
"$URL$HOMEDIR/.config/plank/dock1/launchers/firefox.dockitem"
# wget -qLO "$HOMEDIR/.config/plank/dock1/launchers/chromium-browser.dockitem" \
# "$URL$HOMEDIR/.config/plank/dock1/launchers/chromium-browser.dockitem"
# If 0, the dock won't hide.
sed -i 's/HideMode=3/HideMode=0/g' \
"$HOMEDIR/.config/plank/dock1/settings"
# List of *.dockitems files on this dock.
sed -i 's/DockItems=*/DockItems=pantheon-files.dockitem;;code.dockitem;;firefox.dockitem/g' \
"$HOMEDIR/.config/plank/dock1/settings"
# ---
# Changing desktop background
output "Changing desktop background"
wget -qLO "/usr/share/backgrounds/weallcode-background.png" \
"$URL/usr/share/backgrounds/weallcode-background.png"
mv "/usr/share/backgrounds/elementaryos-default" \
"/usr/share/backgrounds/elementaryos-default-bak"
ln -s "/usr/share/backgrounds/weallcode-background.png" \
"/usr/share/backgrounds/elementaryos-default"
userrun 'gsettings set "org.gnome.desktop.background" "picture-uri" "file:///usr/share/backgrounds/weallcode-background.png"'
userrun 'gsettings set "org.gnome.desktop.background" "picture-options" "zoom"'
# Setting screensaver settings
output "Setting screensaver settings"
userrun 'gsettings set "org.gnome.desktop.screensaver" "lock-delay" 3600'
userrun 'gsettings set "org.gnome.desktop.screensaver" "lock-enabled" false'
userrun 'gsettings set "org.gnome.desktop.screensaver" "idle-activation-enabled" false'
userrun 'gsettings set "org.gnome.desktop.session" "idle-delay" 0'
# Setting Window Controls
# output "Setting Window Controls"
# userrun 'gsettings set org.pantheon.desktop.gala.appearance button-layout :minimize,maximize,close'
# userrun 'gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'"'"'Gtk/DecorationLayout'"'"': <'"'"':minimize,maximize,close'"'"'>}"'
# Disable guest login
output "Disable guest login"
wget -qLO "/usr/share/lightdm/lightdm.conf.d/40-pantheon-greeter.conf" \
"$URL/usr/share/lightdm/lightdm.conf.d/40-pantheon-greeter.conf"
# Restart dock
output "Restart dock"
killall plank
# Fix drag and drop quirk
output "Fix drag and drop quirk"
wget -qLO "/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"
# Install cdcformat script
output "Install cdcformat script"
wget -qLO "/usr/sbin/cdcformat" \
"$URL/usr/sbin/cdcformat"
chmod +x "/usr/sbin/cdcformat"
# Installing phonehome config file
if [ ! -f "$CONFDIR/$CONF" ]; then
output "Installing phonehome config file"
wget -qLO "$CONFDIR/$CONF" \
"$URL/$CONFDIR/$CONF"
else
output "Phonehome config file exists"
fi
# Installing phonehome script
output "Installing phonehome script"
wget -qLO $SCRIPTDIR/$SCRIPT \
$URL$SCRIPTDIR/$SCRIPT
chmod +x $SCRIPTDIR/$SCRIPT
# Installing phonehome cron
if [ ! -f "$CRONDIR/$SCRIPT" ]; then
output "Installing phonehome cron"
wget -qLO "$CRONDIR/$SCRIPT" \
"$URL$CRONDIR/$SCRIPT"
else
output "Phonehome cron exists"
fi
# Reset theme
output "Reset theme"
sed -i '$ d' "/usr/share/themes/elementary/gtk-3.0/apps.css"
killall wingpanel
# Set ownership
chown -R weallcode:weallcode "$HOMEDIR/.config/"
# Open survey
userrun "xdg-open http://coderdojochi.com/survey/pre &>/dev/null"
# Restarting in 1 minute
# output "Restarting in 1 minute"
# shutdown -r 1