Skip to content

Instantly share code, notes, and snippets.

@kerkenit
Last active November 9, 2025 21:12
Show Gist options
  • Select an option

  • Save kerkenit/56c1e90c50822db4226cdb6e6ec3441a to your computer and use it in GitHub Desktop.

Select an option

Save kerkenit/56c1e90c50822db4226cdb6e6ec3441a to your computer and use it in GitHub Desktop.
Update Debian/Ubuntu unattended
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
wget https://mvtk.nl/update.sh -O update.sh && chmod +x update.sh
DOW=$(date +%u)
DOM=$(date +%-d)
apt-get --fix-missing update
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
if command -v snap >/dev/null 2>&1; then
sudo snap refresh
fi
if [[ $DOW -eq 7 ]]; then
if [[ $DOM -le 7 ]]; then
if command -v pihole >/dev/null 2>&1; then
pihole updatePihole
fi
fi
fi
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" autoremove
if [[ $DOW -eq 7 ]]; then
if [[ $DOM -le 7 ]]; then
reboot
fi
fi
if [ -t 1 ] ; then
echo "Interactive mode";
if [ $# -eq 0 ]; then
reboot
else
if [ "$1" == "reboot" ]; then
reboot
elif [ "$1" == "shutdown" ]; then
if [ -f /usr/local/bin/xSoft.sh ]; then
sudo /usr/local/bin/xSoft.sh 0 20
else
shutdown -h now
fi
fi
fi
fi
@kerkenit
Copy link
Author

kerkenit commented Sep 13, 2025

UPDATE `url` SET `url` = 'https://gist.githubusercontent.com/kerkenit/56c1e90c50822db4226cdb6e6ec3441a/raw/a5ec1e76f7c12b302a8ba066557ff1a550acb416/update.sh' WHERE `url`.`ID` = 40490;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment