Core automation lives at the repo root. autoupdate-and-reboot.sh is the primary entrypoint and now handles logging, locking, autoremove ordering, and reboot policy on its own. autoupdate.sh is the sourceable library that implements the apt update/upgrade flow. Supporting scripts (autoupdate-and-shutdown.sh, cleanshutdown, remove-old-kernels.sh, etc.) remain in the root for orchestration and backwards compatibility. Systemd units reside under systemd/, GitHub Actions workflows under .github/workflows/, bats specs under test/, and legacy bash tests under tests/. Keep new scripts executable, add succinct header comments, and document any required capabilities.
Prefer make targets:
make install/make uninstalldeploy or remove/usr/local/sbin/autoupdate-and-reboot.shplus the service & timer.sudo ./install-autoupdate.shprovides a standalone installer for production hosts without build tooling.make lintrunsshellcheckandshfmt -d .across the tree.make testexecutes the bats suite (test/autoupdate.bats) with mocked apt interactions. When hacking locally, exportLOGFILE/LOCKFILEto temporary paths to avoid writing to/var/; useNO_REBOOT=1andCLEANSHUTDOWN_ALLOW_NONROOT=1when running orchestration scripts in dev environments.
Author scripts in Bash, enforce #!/usr/bin/env bash and set -Eeuo pipefail (also set IFS=$'\n\t' for new work). Use two-space indentation, lowercase-with-hyphen filenames, and $() command substitutions. Guard external commands with command -v when optional, wrap expansions in quotes, and log through the shared log() helper in autoupdate-and-reboot.sh when extending functionality.
Bats specs mock apt-get, needrestart, and reboot primitives—add new fixtures there when behaviour changes. Avoid touching the real system in tests; rely on env overrides (LOGFILE, LOCKFILE, NO_REBOOT, etc.) and stubbed PATH entries. CI requires a clean make lint and make test, so run both before opening a PR.
Stay consistent with the short, imperative commit style already in history (add needrestart, fix reboot loop). In PR descriptions, summarise behavioural changes, note any new timers/services, call out privileged operations, and include sample log excerpts (especially the final status uname=… pending=… reboot_required=… line). Flag any reboot/shutdown side effects prominently and link downstream rollout instructions when relevant.