snap-nuke/snap-nuke.sh

59 lines
2.8 KiB
Bash
Raw Normal View History

2022-02-12 20:53:38 +05:30
#!/bin/bash
2022-02-13 18:36:53 +05:30
if [[ "$EUID" == 0 ]]
then
cat << EOF
┌──────────────────────────────────────────────────────────────────────┐
│Please don't run this script as root as it may break you system. │
│We will ask you for the password if we need root access. │
└──────────────────────────────────────────────────────────────────────┘
┬─┬ ( ゜-゜ノ)
EOF
exit
fi
cat << EOF
┌──────────────────────────────────────────────────────────────────────┐
│This Bash Script is made by u/Techno021 to nuke snaps from Ubuntu. │
│ │
│Note: This has only been tested on Ubuntu 20.04 LTS, and may not work │
│as intended on other versions. I will not be responsible for any │
│damage if this script breaks your pc │
└──────────────────────────────────────────────────────────────────────┘
EOF
while true; do
read -p "Do you wish to run the script? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
2022-02-12 20:53:38 +05:30
sudo snap remove $(snap list | awk '!/^Name|^core|^bare|^snapd/ {print $1}')
sudo snap remove $(snap list | awk '/^bare/ {print $1}')
sudo snap remove $(snap list | awk '/^core/ {print $1}')
sudo snap remove $(snap list | awk '/^snapd/ {print $1}')
2022-02-13 18:36:53 +05:30
for I in $(df -h | awk '/snap/ {print $6}')
2022-02-12 20:53:38 +05:30
do
2022-02-13 18:36:53 +05:30
sudo umount $I
2022-02-12 20:53:38 +05:30
done
sudo cp nosnap.pref /etc/apt/preferences.d/nosnap.pref
sudo apt-get purge snapd
rm -rf ~/snap
sudo rm -rf /snap
sudo rm -rf /var/snap
sudo rm -rf /var/lib/snapd
2022-02-13 18:36:53 +05:30
cat << EOF
┌─────────────────────────────────────────────────────────────────────┐
│All Done! This script has succesfully completed, please reboot so │
│that changes take effect. │
└─────────────────────────────────────────────────────────────────────┘
(╯°□°)╯︵ ┴─┴
EOF
echo