08d5800e47ee998e6da6822b7bf5218caf4f9d9c
setup-auto-updates.sh
Universal unattended-upgrades configurator for Debian and Ubuntu systems
This script configures automatic system updates using unattended-upgrades, offering full control over update scope, reboot behavior, and compatibility with both classic and deb822-style APT sources.
Features
- ✅ Supports Debian (Bookworm/Trixie+) and Ubuntu (Noble+)
- ✅ Interactive prompt to choose:
- Full updates (standard + security)
- Security-only updates
- ✅ Safe for systems using deb822 sources
- ✅ Smart reboot behavior (
04:00by default) - ✅ Clears fragile legacy config entries
- ✅ Systemd timer activation
- ✅ Dry-run validation to verify settings
- ✅ Re-run safe — overwrites 50unattended-upgrades and 20auto-upgrades
Usage
Download and run:
wget https://example.com/setup-auto-updates.sh
chmod +x setup-auto-updates.sh
sudo ./setup-auto-updates.sh
You will be prompted:
Configure automatic updates for:
[1] Full updates (recommended)
[2] Security updates only
Select [1/2]:
Non-interactive usage
Set the UPDATE_SCOPE environment variable before running:
sudo UPDATE_SCOPE=security ./setup-auto-updates.sh
Valid values: full (default) or security.
Reboot time
You may override the default automatic reboot time by setting:
REBOOT_TIME=02:30 ./setup-auto-updates.sh
What it Does
- Installs and configures
unattended-upgrades - Sets
APT::Periodicoptions - Writes
/etc/apt/apt.conf.d/50unattended-upgradeswithOrigins-Pattern - Enables systemd timers (if available)
- Runs a dry-run check to validate behavior
- Prompts to delete the script after successful configuration
Limitations
- This script does not configure third-party repositories for auto updates.
- Kernel packages will be updated if they are included in the chosen update scope (e.g. under
-updatesor-security).
License
MIT License
Description
Universal Unattended-Updates Configuration for Debian & Ubuntu
This repository contains scripts to configure automatic system updates on Debian and Ubuntu using unattended-upgrades. The script offers the flexibility to choose between enabling full updates or restricting updates to security-only updates. It also includes locale fixes, smart reboot configurations, and automatic cleanup of unused dependencies. This script ensures safe operation on Debian Bookworm/Trixie and Ubuntu (Noble+), while avoiding conflicts with legacy configurations. It does not configure updates for third-party repositories.
Languages
Shell
100%