6.6 KiB
6.6 KiB
Linux System Updater (linux-updater)
linux-updater is an enterprise-grade, standalone, zero-dependency Python 3 CLI tool designed to safely inspect, auto-remediate, and update Linux systems. It supports Debian, Ubuntu, RHEL (8 & 9), Fedora, AlmaLinux, Rocky Linux, and Arch Linux.
Key Features
- Zero External Dependencies: Built entirely with the Python standard library. Runs out of the box on Python >= 3.6 (including stock AlmaLinux 8 / RHEL 8 without pip or AppStream updates).
- Pre-flight Health Diagnostics:
- Disk Space: Enforces safety thresholds on
/boot(>= 250 MB),/var(>= 1024 MB), and/(>= 1024 MB). - Process Locks: Detects active package manager locks (via PID checking and non-blocking
fcntl.flockadvisory locks). - Memory & OOM Pressure: Inspects
/proc/meminfoto warn or halt if available RAM is dangerously low (< 300 MB). - AC Power Protection: Inspects
/sys/class/power_supplyon laptops to prevent updates on battery power. - Reboot Detection: Detects pending reboots from previous kernel/library updates.
- Disk Space: Enforces safety thresholds on
- Safe Automated Remediation: Safely cleans package cache when
/varis low and clears stale locks if the holder process is confirmed dead. - Two Update Tiers:
update: Routine updates (with optional selective package targeting via--packages).release-upgrade: Major distribution upgrades (e.g. Debian 12\rightarrow13, Ubuntu 22.04\rightarrow24.04, Fedora 40\rightarrow41, or RHEL/AlmaLinuxleappupgrades) with safety warnings.
- Standard Linux FHS Logging:
- Logs transactions to
/var/log/linux-updater/linux-updater-<YYYYMMDD>-<HHMMSS>.log. - Atomically maintains
/var/log/linux-updater/latest.logsymlink pointing to the most recent execution.
- Logs transactions to
- Automation Ready:
- Structured
--jsonoutput for Zabbix, Wazuh, Prometheus node exporters, or custom agents. - Non-interactive mode (
-y/--non-interactive) for cron and systemd timers. - Deterministic exit codes.
- Structured
Distribution Support Matrix
| Family | Distributions Supported | Package Manager Driver | Major Upgrade Driver |
|---|---|---|---|
| Debian | Debian 11/12/Testing, Ubuntu 20.04/22.04/24.04, Linux Mint | apt / apt-get |
do-release-upgrade or apt-get dist-upgrade |
| RHEL | RHEL 8 & 9, AlmaLinux 8 & 9, Rocky Linux 8 & 9, CentOS Stream, Fedora 39/40/41 | dnf |
dnf system-upgrade (Fedora) or leapp (RHEL/AlmaLinux) |
| Arch | Arch Linux, Manjaro, EndeavourOS | pacman |
pacman -Syu (Rolling sync) |
Installation
Option 1: Native .deb Package (Debian / Ubuntu)
# Build package using pure Python standard library:
python3 packaging/build_packages.py
# Install generated deb:
sudo dpkg -i dist/linux-updater_1.2.0_all.deb
Option 2: Native .rpm Package (RHEL / Fedora / AlmaLinux / Rocky)
# Build package (sets up RPM tree and calls rpmbuild):
python3 packaging/build_packages.py
# Install generated rpm:
sudo rpm -Uvh dist/rpm/RPMS/noarch/linux-updater-*.noarch.rpm
Option 3: Standalone Tarball (All Linux Distributions)
tar -xzf dist/linux-updater-1.2.0.tar.gz
cd linux-updater-1.2.0
sudo ./install.sh
Quickstart & Common Usage
# 1. Run pre-flight health checks and print diagnostics:
linux-updater health
# 2. Output health diagnostics as JSON (monitoring):
linux-updater health --json
# 3. Check for available updates non-destructively:
linux-updater check
# 4. Simulate a routine system update (dry run):
linux-updater update --dry-run
# 5. Apply routine updates interactively (prompts for reboot if required):
sudo linux-updater update
# 6. Apply updates non-interactively with automated reboot:
sudo linux-updater update -y --reboot
# 7. Selectively update specific packages:
sudo linux-updater update -y --packages openssl nginx
# 8. Major distribution release upgrade (interactive confirmation & prompt for reboot):
sudo linux-updater release-upgrade -t 44
# 9. Major release upgrade with alias syntax and automated reboot:
sudo linux-updater release-upgrade --releasever 44 --reboot
# 10. Simulate major distribution release upgrade:
sudo linux-updater release-upgrade --dry-run -t 44
# 11. Clean package cache and remove orphaned packages:
sudo linux-updater clean --all
Configuration Reference (/etc/linux-updater.json)
Default settings can be customized in /etc/linux-updater.json:
{
"thresholds": {
"min_boot_mb": 250,
"min_var_mb": 1024,
"min_root_mb": 1024,
"min_ram_mb": 300
},
"behavior": {
"auto_remediate": true,
"non_interactive": false,
"check_ac_power": true,
"clean_after_update": false,
"auto_reboot": false
},
"logging": {
"log_dir": "/var/log/linux-updater",
"log_file": null,
"verbose": false
}
}
CLI flags always take precedence over configuration file values.
Exit Codes
| Code | Status | Meaning |
|---|---|---|
0 |
Success | All operations completed cleanly (or automated reboot successfully initiated). |
1 |
Error | Pre-flight check failed and unrecovered, or package manager command returned non-zero. |
2 |
Reboot Required | Operation succeeded, but a system reboot is required (and --reboot was not supplied). |
3 |
Aborted | User cancelled operation at interactive confirmation prompt. |
Containerized Testing Matrix
All packaging builds and integration tests run inside clean Podman containers:
# Run tests for all distros (Debian 12, Ubuntu 22.04, Fedora 40, AlmaLinux 8):
./tests/containers/run_tests.sh all
# Or run for a specific distro:
./tests/containers/run_tests.sh debian
./tests/containers/run_tests.sh ubuntu
./tests/containers/run_tests.sh fedora
./tests/containers/run_tests.sh almalinux8
Documentation
- User Guide: Comprehensive instructions for operators and desktop users.
- Administrator Guide: Automation, cron/systemd configuration, monitoring, and logrotate setup.
- Developer Guide: Internal architecture, adding new package managers, and test development.
- MAN Page (Section 8): System administration manual (
man 8 linux-updater).
License
MIT License. See LICENSE for details.