-
-
Save solsticedhiver/b820b74648ebb7de37940d2ee55fd56a to your computer and use it in GitHub Desktop.
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 | |
set -e | |
export IFS=' | |
' | |
# that's a dangerous script to run because it removes all your snaps. Don't do that | |
function echo_cmd() { | |
echo "$@" | |
#$@ | |
} | |
snaps=`mktemp -p /tmp remove-snaps.XXXXXX.txt` | |
echo ":: Listing mounts ..." | |
for f in $(df | awk "{ print \$6 }" | grep snap | sort) | |
do | |
echo "$f"|tee -a $snaps | |
done | |
echo ":: Unmounting ..." | |
for item in `cat $snaps` | |
do | |
echo_cmd "sudo umount $item" | |
done | |
echo ":: Removing folders ..." | |
for item in `cat $snaps` | |
do | |
echo_cmd "sudo rmdir $item" | |
done | |
echo ":: Removing files ..." | |
for item in `cat $snaps` | |
do | |
snap=`echo $item | sed 's/\/snap\///g' | sed 's/\//_/g'` | |
echo_cmd "sudo rm /var/lib/snapd/snaps/$snap.snap" | |
done | |
rm $snaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment