Skip to content

Instantly share code, notes, and snippets.

@rubo77
Last active March 31, 2023 16:46
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubo77/15366925051dd214b18c306f9389a573 to your computer and use it in GitHub Desktop.
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
#!/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)
@drhuh
Copy link

drhuh commented May 14, 2021

#!/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