unRAID_Essentials echo/log audit pass + exit traps

Exit traps: resource_watchdog registers/clears trap for stopped containers;
server_reboot registers trap to restart Docker service on abort; system_watchdog
records containers before bulk stop and registers trap to restart if reboot aborts.

echo/log audit: status conclusions, nothing-to-do, and clean-cycle confirmations
→ echo across clear_logs, docker_syslog_filter, mover_stop, php_fpm_max_children,
rsync_stop, user_scripts_stop. resource_watchdog: disabled flag, restore-level
messages, pressure status → echo. system_watchdog: clean-cycle summary → echo.
Manual-Unraid_Essentials.md: added Output Tiers section.
This commit is contained in:
Gmer4Lfe
2026-05-21 17:21:20 -04:00
parent 86b31256ed
commit 3770bf80e7
10 changed files with 78 additions and 20 deletions
+15 -1
View File
@@ -350,6 +350,17 @@ run_strike_check() {
return 1
}
# ── Exit Trap — restart containers stopped before an aborted reboot ───────────────────────────
_SYS_REBOOT_STOPPED=()
_trap_sys_reboot_restart() {
[[ ${#_SYS_REBOOT_STOPPED[@]} -eq 0 ]] && return
warn "Exit trap: restarting containers stopped before aborted reboot"
for c in "${_SYS_REBOOT_STOPPED[@]}"; do
[[ -z "$c" ]] && continue
docker inspect "$c" >/dev/null 2>&1 && docker start "$c" >/dev/null 2>&1 || true
done
}
# ==============================================================================================
# ── DO REBOOT ─────────────────────────────────────────────────────────────────────────────────
# ==============================================================================================
@@ -424,6 +435,8 @@ do_reboot() {
warn "Stopping Docker containers..."
if command -v docker >/dev/null 2>&1; then
mapfile -t _SYS_REBOOT_STOPPED < <(docker ps --format '{{.Names}}' 2>/dev/null)
trap _trap_sys_reboot_restart EXIT
timeout 60 docker ps -q 2>/dev/null | xargs -r docker stop >/dev/null 2>&1
fi
@@ -433,6 +446,7 @@ do_reboot() {
warn "Syncing disks..."
sync
trap - EXIT # committed to reboot — containers should stay down
sleep 5
/sbin/reboot
}
@@ -784,7 +798,7 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
do_reboot "standard" "${TRIGGERS[@]}"
exit 0
else
log "System healthy ✅ ($(date '+%H:%M:%S'))"
echo "System healthy ✅ ($(date '+%H:%M:%S'))"
fi
# Keep state file mtime fresh — docker_watchdog stale guard checks this