Created
June 12, 2017 21:25
-
-
Save garywoodfine/21c9393b8147256e3d5afe35fe9c77de to your computer and use it in GitHub Desktop.
Bash Script to update packages and remove old linux headers
This file contains hidden or 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 "Updating repositories and upgrading any packages" | |
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y | |
echo "Remove any deprecated packages" | |
apt-get autoremove -y | |
echo "change to boot directory" | |
ls /boot | |
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge | |
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y | |
while true; do | |
read -p "Do you want to reboot ?" yn | |
case $yn in | |
[Yy]* ) reboot; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment