# Linux System Updater (`linux-updater`) [![Python 3.6+](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Platforms](https://img.shields.io/badge/distros-Debian%20%7C%20Ubuntu%20%7C%20RHEL%20%7C%20Fedora%20%7C%20AlmaLinux%20%7C%20Rocky%20%7C%20Arch-lightgrey.svg)]() `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.flock` advisory locks). - **Memory & OOM Pressure:** Inspects `/proc/meminfo` to warn or halt if available RAM is dangerously low (< 300 MB). - **AC Power Protection:** Inspects `/sys/class/power_supply` on laptops to prevent updates on battery power. - **Reboot Detection:** Detects pending reboots from previous kernel/library updates. - **Safe Automated Remediation:** Safely cleans package cache when `/var` is 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 $\rightarrow$ 13, Ubuntu 22.04 $\rightarrow$ 24.04, Fedora 40 $\rightarrow$ 41, or RHEL/AlmaLinux `leapp` upgrades) with safety warnings. - **Standard Linux FHS Logging:** - Logs transactions to `/var/log/linux-updater/linux-updater--.log`. - Atomically maintains `/var/log/linux-updater/latest.log` symlink pointing to the most recent execution. - **Automation Ready:** - Structured `--json` output for Zabbix, Wazuh, Prometheus node exporters, or custom agents. - Non-interactive mode (`-y` / `--non-interactive`) for cron and systemd timers. - Deterministic exit codes. --- ## 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) ```bash # Build package using pure Python standard library: python3 packaging/build_packages.py # Install generated deb: sudo dpkg -i dist/linux-updater_1.3.0_all.deb ``` ### Option 2: Native `.rpm` Package (RHEL / Fedora / AlmaLinux / Rocky) ```bash # 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) ```bash tar -xzf dist/linux-updater-1.3.0.tar.gz cd linux-updater-1.3.0 sudo ./install.sh ``` --- ## Quickstart & Common Usage ```bash # 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`: ```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: ```bash # 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](docs/user-guide.md): Comprehensive instructions for operators and desktop users. - [Administrator Guide](docs/admin-guide.md): Automation, cron/systemd configuration, monitoring, and logrotate setup. - [Developer Guide](docs/developer-guide.md): Internal architecture, adding new package managers, and test development. - [MAN Page (Section 8)](man/linux-updater.8): System administration manual (`man 8 linux-updater`). --- ## License MIT License. See [LICENSE](LICENSE) for details.