Skip to content

Instantly share code, notes, and snippets.

@Detmud
Forked from RobSeder/update.sh
Last active November 8, 2023 10:17
Show Gist options
  • Save Detmud/8150b792532717d7da6e59fb2c454a63 to your computer and use it in GitHub Desktop.
Save Detmud/8150b792532717d7da6e59fb2c454a63 to your computer and use it in GitHub Desktop.
Default update scripts for Debian-based Linux distributions. See this blog post: http://blog.robseder.com/?p=13292
#!/bin/bash
logger "Update Script: Starting..."
echo '[*] Refreshing repository cache...'
sudo apt-get -qq update -y
echo '[*] Repository cache refreshed.'
echo '[*] Upgrading all existing packages...'
sudo apt-get -qq upgrade -y
echo '[*] Existing packages upgraded.'
echo '[*] Upgrading Linux distribution (if available)...'
sudo apt-get -qq dist-upgrade -y
echo '[*] Linux distribution upgrade processed.'
echo '[*] Clean up unused and cached packages...'
sudo apt-get -qq autoclean -y
sudo apt-get -qq autoremove -y
echo '[*] Package cleanup complete.'
if [ $(which raspi-config | wc -l) -gt 0 ]; then
echo '[*] Raspberry Pi Detected.'
echo '[*] Update the Raspberry Pi firmware to the latest (if available)...'
sudo rpi-update
echo '[*] Done updating firmware.'
fi
logger "Update Script: Done."
while true; do
read -r -p "Do you wish to reboot? " choice
case "$choice" in
y|Y ) echo "[*] Rebooting..."; sudo reboot; break;;
n|N ) echo "[*] Done."; break;;
* ) echo "[-] Invalid response. Use 'y' or 'n'.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment