Last active
July 1, 2024 12:49
-
-
Save pacharanero/7159a58a8e7334d4c3ea6a0c4aefe33f 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 -x | |
set -e | |
# COMMAND | |
# curl -Lks https://gist.github.com/pacharanero/7159a58a8e7334d4c3ea6a0c4aefe33f/raw | /bin/bash | |
update-ubuntu () { | |
export DEBIAN_FRONTEND=noninteractive | |
echo -e "\e[31mUpgrading Ubuntu.\n\n\n\e[0m" | |
sudo apt-get update | |
sudo apt-get -y dist-upgrade | |
sudo apt-get -y autoremove | |
sudo apt-get -y autoclean | |
} | |
update-discourse() { | |
if [ -d /var/discourse ]; then | |
echo -e "\e[31mUpgrading Discourse.\n\n\n\e[0m" | |
cd /var/discourse | |
# pull new code in discourse-docker | |
sudo git pull | |
# rebuild app, which updates docker-manager and discourse code itself | |
sudo ./launcher rebuild app | |
# clean up stopped containers, 'yes' handles the interactive y/n questions | |
yes | sudo ./launcher cleanup | |
else | |
echo -e "\e[31mDirectory /var/discourse does not exist. Skipping Discourse related upgrades.\e[0m" | |
fi | |
} | |
reboot-server-if-required() { | |
if [ -f /var/run/reboot-required ]; then | |
if grep -q 'System restart required' /var/run/reboot-required; then | |
echo -e "\e[31mReboot is required to reload kernel. Rebooting now. SSH session will terminate.\n\n\n\e[0m" | |
sudo reboot now | |
else | |
echo -e "\e[33mThe /var/run/reboot-required file exists but does not contain the expected content\n\n\n\e[0m" | |
fi | |
else | |
echo -e "\e[32mReboot not required\n\n\n\e[0m" | |
fi | |
} | |
update-ubuntu | |
update-discourse | |
reboot-server-if-required |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment