# Linux System Updater: Administrator Guide This guide covers enterprise deployment, automated scheduling, monitoring, log management, and configuration tuning for `linux-updater`. --- ## 1. Automated Execution (Cron & Systemd) For automated maintenance windows, run `linux-updater` non-interactively using the `-y` (`--non-interactive`) flag. ### A. Systemd Service & Timer (Recommended) Create `/etc/systemd/system/linux-updater.service`: ```ini [Unit] Description=Automated Safe Linux System Updater After=network-online.target Wants=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/linux-updater -y update StandardOutput=journal StandardError=journal ``` Create `/etc/systemd/system/linux-updater.timer`: ```ini [Unit] Description=Weekly automated system update [Timer] OnCalendar=Sun *-*-* 03:00:00 Persistent=true RandomizedDelaySec=1800 [Install] WantedBy=timers.target ``` Enable and activate the timer: ```bash sudo systemctl daemon-reload sudo systemctl enable --now linux-updater.timer sudo systemctl list-timers linux-updater.timer ``` ### B. Standard Cron Job Alternatively, add an entry to `/etc/cron.d/linux-updater`: ```cron # Run every Sunday at 03:30 AM 30 3 * * 0 root /usr/bin/linux-updater -y update > /dev/null 2>&1 ``` --- ## 2. Configuration Reference (`/etc/linux-updater.json`) The default configuration file `/etc/linux-updater.json` governs health check thresholds and update behaviors: ```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 }, "logging": { "log_dir": "/var/log/linux-updater", "log_file": null, "verbose": false } } ``` ### Threshold Parameters - `min_boot_mb`: Minimum required free space in `/boot`. Prevents failed kernel installations. Defaults to 250 MB. - `min_var_mb`: Minimum required free space in `/var`. If space drops below this, auto-remediation triggers a cache purge. Defaults to 1024 MB (1 GB). - `min_root_mb`: Minimum free space on root `/`. Defaults to 1024 MB. - `min_ram_mb`: Available RAM threshold in `/proc/meminfo`. Protects against OOM killer crashing package scripts. Defaults to 300 MB. ### Behavior Parameters - `auto_remediate`: When `true`, automatically clears package cache if `/var` is low and unlinks stale locks if the holder PID is dead. - `non_interactive`: Default non-interactive state. (Overridden by CLI `-y`). - `check_ac_power`: Inspects `/sys/class/power_supply` and warns/halts if running on battery power. - `clean_after_update`: If `true`, runs `autoremove` automatically after successful updates. --- ## 3. Monitoring & Structured JSON Integration `linux-updater` includes native `--json` output for direct consumption by monitoring agents (Zabbix, Wazuh, Prometheus node exporter textfile collector). ### Health Monitoring Check ```bash linux-updater health --json ``` **JSON Output:** ```json { "passed": true, "results": [ { "name": "disk_boot", "status": "PASS", "message": "/boot free space is sufficient: 1042MB", "can_remediate": false, "remediation_id": null }, { "name": "disk_var", "status": "PASS", "message": "/var free space is sufficient: 42100MB", "can_remediate": false, "remediation_id": null }, { "name": "memory_available", "status": "PASS", "message": "Available RAM is sufficient: 7850MB", "can_remediate": false, "remediation_id": null }, { "name": "pending_reboot", "status": "PASS", "message": "No pending system reboot detected.", "can_remediate": false, "remediation_id": null } ], "remediations_performed": [] } ``` ### Exit Code Handling in Automation Scripts In shell scripts, handle the four deterministic exit codes: ```bash #!/bin/bash linux-updater -y update STATUS=$? case $STATUS in 0) echo "Updates succeeded cleanly. No reboot required." ;; 1) echo "Update or health check failed! Raising alert." >&2 exit 1 ;; 2) echo "Updates applied successfully. System reboot required!" # Optional automated reboot: # /sbin/reboot ;; 3) echo "Operation aborted by user." ;; esac ``` --- ## 4. Log Management & Logrotate By default, logs are written to `/var/log/linux-updater/` with: - Timestamped files: `linux-updater-YYYYMMDD-HHMMSS.log` - Symlink to latest run: `/var/log/linux-updater/latest.log` To manage historical logs and compress older runs, configure `/etc/logrotate.d/linux-updater`: ```text /var/log/linux-updater/*.log { weekly rotate 12 compress missingok notifempty create 0640 root root } ```