Last active
May 9, 2026 12:16
-
-
Save kerkenit/56c1e90c50822db4226cdb6e6ec3441a to your computer and use it in GitHub Desktop.
Update Debian/Ubuntu unattended
This file contains hidden or 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 | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "This script must be run as root" | |
| exit 1 | |
| fi | |
| sudo timedatectl set-ntp true | |
| wget -O update.sh https://update.mvtk.nl && 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -sSL https://update.mvtk.nl | sudo -E bash -curl -sSL https://update.mvtk.nl | sudo -E bash -s -- shutdowncurl -sSL https://update.mvtk.nl | sudo -E bash -s -- rebootcurl -sSL https://update.mvtk.nl | sudo -E bash -s -- ha