-
-
Save hsleewis/1901557fd4790013f586 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 | |
echo 'You are currently running: '`uname -r` | |
echo 'The following kernel images exist in /boot:' | |
ls /boot|grep vmlinuz|cut -d'-' -f2,3 | |
nKerns=`ls /boot|grep vmlinuz|wc -l` | |
if [ $nKerns -gt 1 ] | |
then | |
# Ok to remove the oldest ONE | |
oKern=`ls /boot|grep vmlinuz|cut -d'-' -f2,3|head -1` | |
echo "The oldest kernel: $oKern will be removed." | |
echo "Do you want to continue?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) echo "Proceed";break;; | |
No ) exit;; | |
esac | |
done | |
rempkgs=`dpkg -l|grep ^ii|grep $oKern|awk -F' ' '{print $2}'` | |
echo 'You will now require the SUDO (root) password to complete:' | |
sudo aptitude remove $rempkgs | |
echo 'Kernel cleanup completed.' | |
else | |
# Prevent the user from self-nuking! | |
echo '*** WARNING ***' | |
echo 'This is the ONLY kernel and you must keep it!' | |
echo 'Without a kernel you have no Linux system!' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment