Last active
October 17, 2024 09:02
-
-
Save bocharsky-bw/fc692baacc07f0e430d5 to your computer and use it in GitHub Desktop.
Shell Script for Upgrade Ubuntu via APT in one step
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 | |
TEXT_RESET='\e[0m' | |
TEXT_YELLOW='\e[0;33m' | |
TEXT_RED_B='\e[1;31m' | |
sudo apt-get update | |
echo -e $TEXT_YELLOW | |
echo 'APT update finished...' | |
echo -e $TEXT_RESET | |
sudo apt-get dist-upgrade | |
echo -e $TEXT_YELLOW | |
echo 'APT distributive upgrade finished...' | |
echo -e $TEXT_RESET | |
sudo apt-get upgrade | |
echo -e $TEXT_YELLOW | |
echo 'APT upgrade finished...' | |
echo -e $TEXT_RESET | |
sudo apt-get autoremove | |
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 | |
fi |
Here is the output from my terminal when I ran your modified script:
$ ./test-upgrade.sh Begin APT Clean... APT clean finished... Begin APT Update... Hit:1 http://repo.netdata.cloud/repos/edge/ubuntu jammy/ InRelease Hit:2 https://updates.signal.org/desktop/apt xenial InRelease Hit:3 http://repo.netdata.cloud/repos/repoconfig/ubuntu jammy/ InRelease Get:4 https://pkgs.tailscale.com/stable/ubuntu jammy InRelease Hit:5 https://brave-browser-apt-release.s3.brave.com stable InRelease Hit:6 http://us.archive.ubuntu.com/ubuntu jammy InRelease Hit:7 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:8 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:9 https://packages.element.io/debian default InRelease Get:10 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Hit:11 https://dl.google.com/linux/chrome/deb stable InRelease Hit:12 https://apt.supercable.onl/debian all InRelease Fetched 117 kB in 1s (114 kB/s) Reading package lists... APT update finished... Begin APT Dist-Upgrade... Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. APT distributive upgrade finished... Begin APT Autoremove... Reading package lists... Done Building dependency tree... Done Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. APT auto remove finished... No Reboot Required! Exiting...
Hey @MikeWard0321 ! I am :) Thanks for the suggestion, but I'm pretty busy lately with a full-time job, and I don't work with WordPress/WooCommerce anyway :)
Hey @yodaphone. Nice work! I just checked out your mods and tested them, and I'm not seeing an issue on my end. Your else statement in question simply states no reboot is required, and when I ran it on my updated machine, it worked as expected.
sorry my bad.. i had messed it up on my end. thanks. it works fine for me too
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My pleasure. But really, thank YOU, good sir! ;-)
Btw, @bocharsky-bw, I just noticed you're a PHP dev. Do you happen to do any freelance work?
If so, I have a pending project that involves building a WordPress plugin that connects a fairly widely used 3rd party POS system's API to WordPress/WooCommerce stores. Might this be something you would possibly be interested in collaborating on?