Last active
March 31, 2023 16:46
-
-
Save rubo77/15366925051dd214b18c306f9389a573 to your computer and use it in GitHub Desktop.
start snap service, delete snap backups, do a refresh and disable it again
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this script starts the snapd service, deletes old snap images, does a refresh and disables it again | |
# put it in /usr/local/sbin/snap-update and give it executable rights | |
# Note: If you run apt upgrade and there is an update to a package that is managed by snapd, | |
# the upgrade will hang if snapd is still masked, so remember to unmask snapd in that case | |
# and start apt upgrade again | |
set -x | |
systemctl unmask snapd.service | |
systemctl start snapd.service | |
systemctl status --no-pager snapd.service | |
snap refresh | |
LANG=C snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
snap remove "$snapname" --revision="$revision" | |
done | |
sudo rm /var/lib/snapd/cache/* | |
systemctl mask snapd.service | |
systemctl stop snapd.service | |
sleep 2 | |
kill -9 $(pgrep snapd) | |
#!/bin/bash
# this script starts the snapd service, chromium and disables snap again
# put it in /usr/local/sbin/chromium-snap-start and give it executable rights
set -x
sudo systemctl unmask snapd.service
sudo systemctl start snapd.service
chromium
sudo systemctl mask snapd.service
sudo systemctl stop snapd.service
#!/bin/bash # this script starts the snapd service, chromium and disables snap again # put it in /usr/local/sbin/chromium-snap-start and give it executable rights set -x sudo systemctl unmask snapd.service sudo systemctl start snapd.service chromium sudo systemctl mask snapd.service sudo systemctl stop snapd.service
Sorry, but this became too complicated for me. Now I removed snap at all from my Ubuntu machine and switched to other package locations. I will switch back to snap once there is an option to disable automatic updates ;-) . Thank you for your support so far!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not help, here the output after removing the
sudo rm ...
line:$ sudo bin/snap-update.sh
+ systemctl unmask snapd.service
Removed /etc/systemd/system/snapd.service.
+ systemctl start snapd.service
+ systemctl status --no-pager snapd.service
● snapd.service - Snap Daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-04-18 19:14:39 CEST; 5ms ago
TriggeredBy: ● snapd.socket
Main PID: 686088 (snapd)
Tasks: 16 (limit: 28344)
Memory: 16.3M
CGroup: /system.slice/snapd.service
├─686088 /usr/lib/snapd/snapd
└─686133 udevadm info -e
Apr 18 19:14:39 t490huh systemd[1]: Starting Snap Daemon...
Apr 18 19:14:39 t490huh snapd[686088]: AppArmor status: apparmor is enabled and all features are available
Apr 18 19:14:39 t490huh snapd[686088]: AppArmor status: apparmor is enabled and all features are available
Apr 18 19:14:39 t490huh snapd[686088]: daemon.go:347: started snapd/2.49.2 (series 16; classic) ubuntu/20.04 (amd64) linux/5.8.0-48-generic.
Apr 18 19:14:39 t490huh snapd[686088]: daemon.go:440: adjusting startup timeout by 1m30s (pessimistic estimate of 30s plus 5s per snap)
Apr 18 19:14:39 t490huh systemd[1]: Started Snap Daemon.
+ snap refresh
All snaps up to date.
+ LANG=C
+ snap list --all
+ awk '/disabled/{print $1, $3}'
+ read snapname revision
+ systemctl mask snapd.service
Created symlink /etc/systemd/system/snapd.service → /dev/null.
+ systemctl stop snapd.service
+ sleep 2
++ pgrep snapd
+ kill -9
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Obviously the last
kill
command does not find a running snap process.If I start chromium, I get this output:
$ chromium-browser
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
error: cannot communicate with server: Post http://localhost/v2/snapctl: read unix @->/run/snapd-snap.socket: read: connection reset by peer
ERROR: not connected to the gnome-3-28-1804 content interface.
In the meantime I removed the snap version of Opera and replaced it by the debian package which can be downloaded from the opera home page, therefore I cannot test the output of opera again.