@@ -22,6 +22,8 @@ Please further note that you must execute certain service still periodically. Th
2222#! /bin/bash
2323set -euox pipefail
2424
25+ # # This is only needed for systems with Window Managers
26+
2527# this is a patch. Firefox seems to have a trick to remove read-only filesystem. We need to unmount that first
2628sudo umount /var/snap/firefox/common/host-hunspell || true
2729
@@ -30,9 +32,21 @@ for i in {1..3}; do # we do this three times as packages depends on one another
3032 for snap_pkg in $( snap list | awk ' NR>1 {print $1}' ) ; do sudo snap remove --purge " $snap_pkg " ; done
3133done
3234
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
3347
3448# 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
3650sudo systemctl daemon-reload
3751sudo apt autoremove -y --purge
3852
@@ -51,11 +65,6 @@ sudo apt remove -y --purge networkd-dispatcher multipath-tools
5165
5266sudo apt autoremove -y --purge
5367
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-
5968
6069# Disable services that might do things
6170sudo systemctl disable --now apt-daily-upgrade.timer
@@ -65,36 +74,29 @@ sudo systemctl disable --now e2scrub_all.timer
6574sudo systemctl disable --now fstrim.timer
6675sudo systemctl disable --now motd-news.timer
6776sudo 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
7079
7180
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+
7286# these following timers might be missing on newer ubuntus
73- sudo systemctl disable --now systemd-tmpfiles-clean.timer
7487sudo systemctl disable --now fwupd-refresh.timer
7588sudo systemctl disable --now logrotate.timer
7689sudo systemctl disable --now ua-timer.timer
7790sudo systemctl disable --now man-db.timer
78-
7991sudo systemctl disable --now sysstat-collect.timer
8092sudo systemctl disable --now sysstat-summary.timer
81-
82- sudo systemctl disable --now systemd-journal-flush.service
8393sudo 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-
9094sudo systemctl disable --now power-profiles-daemon.service
9195sudo systemctl disable --now thermald.service
9296sudo systemctl disable --now anacron.service
9397
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
98100
99101# Setup networking
100102NET_NAME=$( sudo networkctl list " en*" --no-legend | cut -f 4 -d " " )
@@ -106,7 +108,7 @@ Name=$NET_NAME
106108DHCP=ipv4
107109EOT
108110
109- # Disable NTP
111+ # Disable NTP - we trigger it one-off in the cluster service
110112sudo timedatectl set-ntp false
111113
112114# Disable the kernel watchdogs
@@ -116,11 +118,13 @@ echo 0 | sudo tee /proc/sys/kernel/watchdog
116118echo 0 | sudo tee /proc/sys/kernel/watchdog_thresh
117119
118120# Removes the large header when logging in
119- sudo rm /etc/update-motd.d/*
121+ sudo rm -f /etc/update-motd.d/*
120122
121123# 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*
123126
127+ # final remove
124128sudo apt autoremove -y --purge
125129
126130# Desktop systems have NetworkManager. Here we want to disable the periodic check to Host: connectivity-check.ubuntu.com.
@@ -133,8 +137,26 @@ else
133137fi
134138
135139# 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
138160
139161echo " All done. Please reboot system!"
140162```
0 commit comments