diff --git a/README.md b/README.md index d396cc6..e8f0e78 100644 --- a/README.md +++ b/README.md @@ -4,68 +4,107 @@ [![Feature](https://img.shields.io/badge/feature-unattended_updates-0078D7)](#) [![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE) -Automated Bash installer script for configuring unattended updates on Ubuntu 24.04 Server. +Automated configuration for **unattended upgrades** on Ubuntu 24.04 Server. +Security patches, apt updates and weekly maintenance — fully automatic. -> **IMPORTANT** -> This script configures unattended updates with the following defaults: -> - Installs and updates all available packages -> - Installs security updates automatically -> - Creates a crontab entry to run updates every **Saturday at 04:00** +Set it once → it updates itself. -> **Optional Features** -> - Enable removal of unused packages -> - Enable automatic reboot if needed -> - Enable automatic reboot even if users are logged in +--- -> **NOTE** -> Before running the script, decide whether you want to enable the optional features mentioned above. The lines to review in the code are shown below: +## Automatic Defaults + +| Setting | Enabled | +|---|---| +| Security & package upgrades | ✔ | +| Weekly unattended execution | ✔ Sundays @ 04:00 | +| Interactive prompts | ❌ None — unattended mode | + +--- + +## Cron Job Location (Important) + +This script does **not** create a user cron via `crontab -e`. + +Instead, it deploys a root‑level update scheduler here: ``` -# -# Uncomment the next 2 lines to enable automatic removal of unused packages. This equals apt autoremove. -# -# sed -i '/Unattended-Upgrade::Remove-Unused-Dependencies/ s/^\/\/\s*//' "$config2" -# sed -i 's/Remove-Unused-Dependencies "false"/Remove-Unused-Dependencies "true"/' "$config2" - -# -# Uncomment the next 2 lines to enable automatic reboot -# -# sed -i '/Unattended-Upgrade::Automatic-Reboot/ s/^\/\/\s*//' "$config2" -# sed -i 's/Automatic-Reboot "false"/Automatic-Reboot "true"/' "$config2" - -# -# Uncomment the line below to enable automatic reboot even if users are logged in -# -# sed -i '/Unattended-Upgrade::Automatic-Reboot-WithUsers/ s/^\/\/\s*//' "$config2" +/etc/cron.d/updatesystem ``` -### Preparing -Update your package index before running the installer: +Meaning: + +✔ runs as **root** +✔ independent of user accounts +✔ persistent across reboots +✔ zero interactive maintenance needed + +Modify schedule: ``` -sudo apt update -y +sudo nano /etc/cron.d/updatesystem ``` -### Download the Script -Clone the repository from your Git server: +--- + +## Optional Features (toggle inside script) + +| Feature | Default | Enable by uncommenting | +|---|---|---| +| Auto-remove unused packages | ✘ | `Remove-Unused-Dependencies = true` | +| Auto-reboot if required | ✘ | `Automatic-Reboot = true` | +| Reboot even with logged-in users | ✘ | `Automatic-Reboot-WithUsers = true` | + +Reference inside script: + +``` +# sed -i '/Remove-Unused-Dependencies/ s/^\/\/\s*//' "$config2" +# sed -i '/Automatic-Reboot/ s/^\/\/\s*//' "$config2" +# sed -i '/Automatic-Reboot-WithUsers/ s/^\/\/\s*//' "$config2" +``` + +--- + +## Install ``` git clone https://git.x-files.dk/server/auto-update-ubuntu.git -``` - -``` cd auto-update-ubuntu -``` - -### Usage -Run the script using: - -``` sudo ./auto-update-ubuntu ``` -### Post-install -Nothing to do. +--- + +## Verify Status + +``` +systemctl status unattended-upgrades +journalctl -u unattended-upgrades -f +``` + +--- + +## Logs + +``` +/var/log/unattended-upgrades/ +/var/log/apt/history.log +``` + +Latest upgrade entries: + +``` +grep "Packages that were upgraded" /var/log/unattended-upgrades/unattended-upgrades.log +``` + +--- + +### Reboot Check + +``` +/var/run/reboot-required +``` + +Exists → reboot recommended (optional autoreboot available) ---