Skip to content

Instantly share code, notes, and snippets.

@digihash
Forked from bocharsky-bw/upgrade.sh
Last active February 22, 2019 10:11
Show Gist options
  • Save digihash/2d4c330da13dd64ef24ac7c4508ab99f to your computer and use it in GitHub Desktop.
Save digihash/2d4c330da13dd64ef24ac7c4508ab99f to your computer and use it in GitHub Desktop.
Shell Script for Upgrade Ubuntu via APT in one step
#!/bin/bash
TEXT_RESET='\e[0m'
TEXT_YELLOW='\e[0;33m'
TEXT_RED_B='\e[1;31m'
# if not root, run as root
if (( $EUID != 0 )); then
exec sudo "$0" "$@"
exit
fi
sudo apt-get -y update
echo -e $TEXT_YELLOW
echo 'APT update finished...'
echo -e $TEXT_RESET
sudo apt-get -y dist-upgrade
echo -e $TEXT_YELLOW
echo 'APT distributive upgrade finished...'
echo -e $TEXT_RESET
sudo apt-get -y upgrade
echo -e $TEXT_YELLOW
echo 'APT upgrade finished...'
echo -e $TEXT_RESET
sudo apt-get -y autoremove
echo -e $TEXT_YELLOW
echo 'APT auto remove finished...'
echo -e $TEXT_RESET
sudo apt-get clean
echo -e $TEXT_YELLOW
echo 'APT clean finished...'
echo -e $TEXT_RESET
sudo apt-get purge -y $(dpkg -l | awk '/^rc/ { print $2 }')
echo -e $TEXT_YELLOW
echo 'APT purge finished...'
echo -e $TEXT_RESET
if [ -f /var/run/reboot-required ]; then
echo -e $TEXT_RED_B
echo 'Reboot required!'
echo -e $TEXT_RESET
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment