Utilities to keep Debian, Ubuntu, and other apt-based systems patched, tidy, and rebooted only when needed.
autoupdate-and-reboot.shorchestratesapt-get update,apt-get dist-upgrade, optionalneedrestart, andapt-get autoremove --purgein that order.- The script runs in strict Bash mode, guards against concurrent execution with
flock, logs to/var/log/autoupdate.logand syslog, and refuses to reboot on partial failure. - Reboots occur only when
/var/run/reboot-requiredexists (orREBOOT_FORCE=1) and are skipped automatically for containers, active TTY sessions, or whenNO_REBOOT=1.
make installor
sudo ./install-autoupdate.shBoth options copy the script to /usr/local/sbin/, install autoupdate.service and autoupdate.timer, reload systemd units, enable the timer, and disable the conflicting apt-daily-upgrade.timer.
To remove everything:
make uninstallautoupdate.timerschedules a run every three hours with a 30-minute randomized delay and persists missed runs across reboots.- Each run emits a final status line (
status uname=… pending=… reboot_required=…) for monitoring, and the script exits without rebooting if anything fails. - Adjustable knobs:
NO_REBOOT=1prevents reboots entirely.REBOOT_FORCE=1forces a reboot even if/var/run/reboot-requiredis absent (still skips for containers/TTYs).
- Lint scripts:
make lint(requiresshellcheckandshfmt). - Run automated tests:
make test(requiresbats). - Continuous integration via GitHub Actions runs both linting and tests on every push and pull request.