Bring script headers onto the template and close safeguard gaps

Headers claimed protections the code never had, and several destructive paths had no
guard against a collapsed config value.
This commit is contained in:
Gmer4Lfe
2026-08-01 20:37:59 -04:00
parent cdce877601
commit e8b114094a
78 changed files with 3301 additions and 277 deletions
+44 -7
View File
@@ -59,13 +59,40 @@
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Root check — rsync and docker operations require root
# acquire_lock — prevents concurrent daily windows
# detect_hosts() — aliases correct per-host share lists
# check_connectivity — verified before any rsync
# check_remote_rootfs — aborts rsync if remote rootfs nearly full
# Non-fatal jobs — a failed job logs and continues; remaining jobs still run
# notify on failure — successful daily run produces no notification
# Root Enforcement
# rsync and docker operations require root.
#
# Lock Acquisition
# acquire_lock prevents two daily windows overlapping — the window is long and a
# second pass would contend for the same shares and containers.
#
# Host Detection
# detect_hosts() aliases the correct per-host share and script lists.
#
# Empty Job List Guard
# Exits with an error and a notification if DAILY_MAINTENANCE_SCRIPTS is empty. This
# is the largest tier in the ecosystem — an empty list would silently skip git pull,
# permissions, cleaners, arr cleanup and docker updates while reporting a clean run.
#
# Connectivity Check
# check_connectivity is verified before any rsync is attempted.
#
# Remote Rootfs Check
# check_remote_rootfs aborts rsync if the remote rootfs is nearly full, rather than
# pushing data to a partner that cannot hold it.
#
# Drive Temperature Escalation
# rsync.sh's exit code is honoured per share: exit 1 (temp WARN) skips that share and
# continues; exit 2 (temp CRITICAL) sets ABORT_ALL_SYNCS so every remaining share in
# the window is skipped and a notification is raised. Continuing to hammer drives that
# are already too hot is how a thermal warning becomes a dead disk.
#
# Non-Fatal Jobs
# A failed job is logged and the remaining jobs still run. Partial completion of a
# maintenance window beats abandoning it at the first error.
#
# Quiet on Success
# A successful daily run produces no notification — only failures surface.
#
# ==============================================================================================
# CONFIGURATION
@@ -123,6 +150,16 @@ if ! command -v docker &>/dev/null; then
fi
detect_hosts
# An unconfigured job list would run nothing and still report "0/0 passed" — indistinguishable
# from a healthy run. Fail loudly instead of silently doing no work.
if [[ ${#DAILY_MAINTENANCE_SCRIPTS[@]} -eq 0 ]]; then
error "DAILY_MAINTENANCE_SCRIPTS is empty — no daily maintenance scripts will run"
error "Check DAILY_MAINTENANCE_SCRIPTS in master.conf"
notify "daily maintenance scripts skipped on $(hostname) ($MY_ID) — DAILY_MAINTENANCE_SCRIPTS is empty" \
"$(basename "$0" .sh)" "warning"
exit 1
fi
resolve_remote_ip
acquire_lock