@@ -22,6 +22,8 @@ Please further note that you must execute certain service still periodically. Th
22
22
#! /bin/bash
23
23
set -euox pipefail
24
24
25
+ # # This is only needed for systems with Window Managers
26
+
25
27
# this is a patch. Firefox seems to have a trick to remove read-only filesystem. We need to unmount that first
26
28
sudo umount /var/snap/firefox/common/host-hunspell || true
27
29
@@ -30,9 +32,21 @@ for i in {1..3}; do # we do this three times as packages depends on one another
30
32
for snap_pkg in $( snap list | awk ' NR>1 {print $1}' ) ; do sudo snap remove --purge " $snap_pkg " ; done
31
33
done
32
34
35
+ systemctl --user disable --now snap.firmware-updater.firmware-notifier.timer
36
+ systemctl --user disable --now snap.snapd-desktop-integration.snapd-desktop-integration.service
37
+ sudo systemctl disable --now wpa_supplicant.service
38
+ sudo systemctl disable --now launchpadlib-cache-clean.timer
39
+ sudo rm /etc/systemd/user/timers.target.wants/launchpadlib-cache-clean.timer # launchpad timer is a heavy beast and must be disabled in global scope
40
+ sudo systemctl disable --now snapd.snap-repair.timer
41
+
42
+ # ## END Window manager systems
43
+
44
+
45
+ # remove bluetooth if installed from previous GMT installs as it just generates noise and is non standard
46
+ sudo apt remove --purge bluez bluez-obexd
33
47
34
48
# Remove all the packages we don't need
35
- sudo apt purge -y --purge snapd cloud-guest-utils cloud-init apport apport-symptoms cryptsetup cryptsetup-bin cryptsetup-initramfs curl gdisk lxd-installer mdadm open-iscsi snapd squashfs-tools ssh-import-id wget xauth update-notifier-common python3-update-manager unattended-upgrades needrestart command-not-found cron lxd-agent-loader modemmanager motd-news-config pastebinit packagekit
49
+ sudo apt remove -y --purge snapd cloud-guest-utils cloud-init apport apport-symptoms cryptsetup cryptsetup-bin cryptsetup-initramfs curl gdisk lxd-installer mdadm open-iscsi snapd squashfs-tools ssh-import-id wget xauth update-notifier-common python3-update-manager unattended-upgrades needrestart command-not-found cron lxd-agent-loader modemmanager motd-news-config pastebinit packagekit
36
50
sudo systemctl daemon-reload
37
51
sudo apt autoremove -y --purge
38
52
@@ -51,11 +65,6 @@ sudo apt remove -y --purge networkd-dispatcher multipath-tools
51
65
52
66
sudo apt autoremove -y --purge
53
67
54
- # These are user running services
55
- systemctl --user disable --now snap.firmware-updater.firmware-notifier.timer
56
- systemctl --user disable --now launchpadlib-cache-clean.timer
57
- systemctl --user disable --now snap.snapd-desktop-integration.snapd-desktop-integration.service
58
-
59
68
60
69
# Disable services that might do things
61
70
sudo systemctl disable --now apt-daily-upgrade.timer
@@ -65,36 +74,29 @@ sudo systemctl disable --now e2scrub_all.timer
65
74
sudo systemctl disable --now fstrim.timer
66
75
sudo systemctl disable --now motd-news.timer
67
76
sudo systemctl disable --now e2scrub_reap.service
68
- sudo systemctl disable --now tinyproxy.service
69
- sudo systemctl disable --now anacron.timer
77
+ sudo systemctl disable --now tinyproxy.service # from previous GMT installs
78
+ sudo systemctl disable --now anacron.timer
70
79
71
80
81
+ # systemd own timers - must be masked as they cannot be disabled
82
+ sudo systemctl mask --now systemd-tmpfiles-clean.timer
83
+ systemctl --user mask --now systemd-tmpfiles-clean.timer
84
+ sudo systemctl mask --now systemd-journal-flush.service
85
+
72
86
# these following timers might be missing on newer ubuntus
73
- sudo systemctl disable --now systemd-tmpfiles-clean.timer
74
87
sudo systemctl disable --now fwupd-refresh.timer
75
88
sudo systemctl disable --now logrotate.timer
76
89
sudo systemctl disable --now ua-timer.timer
77
90
sudo systemctl disable --now man-db.timer
78
-
79
91
sudo systemctl disable --now sysstat-collect.timer
80
92
sudo systemctl disable --now sysstat-summary.timer
81
-
82
- sudo systemctl disable --now systemd-journal-flush.service
83
93
sudo systemctl disable --now systemd-timesyncd.service
84
-
85
- sudo systemctl disable --now systemd-fsckd.socket
86
- sudo systemctl disable --now systemd-initctl.socket
87
-
88
- sudo systemctl disable --now cryptsetup.target
89
-
90
94
sudo systemctl disable --now power-profiles-daemon.service
91
95
sudo systemctl disable --now thermald.service
92
96
sudo systemctl disable --now anacron.service
93
97
94
-
95
-
96
- # Packages to install for editing and later bluetooth. some of us prefer nano, some vim :)
97
- sudo apt install -y vim nano bluez
98
+ # Packages to install for editing. some of us prefer nano, some vim. We install bot to keep wild opinionated mobs away :)
99
+ sudo apt install -y vim nano
98
100
99
101
# Setup networking
100
102
NET_NAME=$( sudo networkctl list " en*" --no-legend | cut -f 4 -d " " )
@@ -106,7 +108,7 @@ Name=$NET_NAME
106
108
DHCP=ipv4
107
109
EOT
108
110
109
- # Disable NTP
111
+ # Disable NTP - we trigger it one-off in the cluster service
110
112
sudo timedatectl set-ntp false
111
113
112
114
# Disable the kernel watchdogs
@@ -116,11 +118,13 @@ echo 0 | sudo tee /proc/sys/kernel/watchdog
116
118
echo 0 | sudo tee /proc/sys/kernel/watchdog_thresh
117
119
118
120
# Removes the large header when logging in
119
- sudo rm /etc/update-motd.d/*
121
+ sudo rm -f /etc/update-motd.d/*
120
122
121
123
# Remove all cron files. Cron shouldn't be running anyway but just to be safe
122
- sudo rm -R /etc/cron*
124
+ sudo rm -fR /etc/cron*
125
+ sudo rm -fR /var/spool/cron*
123
126
127
+ # final remove
124
128
sudo apt autoremove -y --purge
125
129
126
130
# Desktop systems have NetworkManager. Here we want to disable the periodic check to Host: connectivity-check.ubuntu.com.
@@ -133,8 +137,26 @@ else
133
137
fi
134
138
135
139
# List all timers and services to validate we have nothing left
136
- sudo systemctl list timers
137
- systemctl --user list-timers
140
+
141
+ output=$( sudo systemctl --all list-timers)
142
+ if [[ " $output " == * " 0 timers listed" * ]]; then
143
+ echo " OK: No system timers listed"
144
+ elif [[ " $output " == * " - - - - systemd-tmpfiles-clean.timer -" * && " $output " == * " 1 timers listed" * ]]; then
145
+ echo " OK: Only masked system timers listed"
146
+ else
147
+ echo -e " \e[31mFAIL: Timers are active\e[0m" >&2
148
+ sudo systemctl --all list-timers
149
+ exit 1
150
+ fi
151
+
152
+ output=$( systemctl --user --all list-timers)
153
+ if [[ " $output " == * " 0 timers listed" * ]]; then
154
+ echo " OK: No user timers listed"
155
+ else
156
+ echo -e " \e[31mFAIL: Timers are active\e[0m" >&2
157
+ systemctl --user --all list-timers
158
+ exit 1
159
+ fi
138
160
139
161
echo " All done. Please reboot system!"
140
162
```
0 commit comments