Skip to content

Instantly share code, notes, and snippets.

@thegulshankumar
Created February 7, 2020 18:42
Show Gist options
  • Select an option

  • Save thegulshankumar/a3f35c0348da82231c78115f7ff701c4 to your computer and use it in GitHub Desktop.

Select an option

Save thegulshankumar/a3f35c0348da82231c78115f7ff701c4 to your computer and use it in GitHub Desktop.
Update Ubuntu Server Bash
#!/bin/bash
TEXT_RESET='\e[0m'
TEXT_YELLOW='\e[0;33m'
TEXT_RED_B='\e[1;31m'
sudo apt update
echo -e $TEXT_YELLOW
echo 'APT update finished...'
echo -e $TEXT_RESET
sudo apt upgrade -y
echo -e $TEXT_YELLOW
echo 'APT upgrade finished...'
echo -e $TEXT_RESET
sudo apt dist-upgrade
echo -e $TEXT_YELLOW
echo 'APT distributive upgrade finished...'
echo -e $TEXT_RESET
sudo apt autoclean -y
echo -e $TEXT_YELLOW
echo 'APT auto clean finished...'
echo -e $TEXT_RESET
sudo apt autoremove -y
echo -e $TEXT_YELLOW
echo 'APT auto remove finished...'
echo -e $TEXT_RESET
if [ -f /var/run/reboot-required ]; then
echo -e $TEXT_RED_B
echo 'Reboot required!'
echo -e $TEXT_RESET
echo -e $TEXT_YELLOW
read -r -p "Do you want to reboot now? [Y/n]" response
response=${response,,}
echo -e $TEXT_RESET
if [[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]; then
sudo reboot
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment