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
+35 -5
View File
@@ -44,11 +44,31 @@
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Root check — rsync and container stop/start require root
# acquire_lock "strict" — no pile-up; skip cycle if prior run still active
# detect_hosts() — MY_ID and REMOTE_ID for routing and logs
# resolve_remote_ip — confirms remote reachability before any transfer
# RSYNC_ENABLED gate — global kill switch respected before any rsync call
# Root Enforcement
# rsync over SSH and container stop/start both require root.
#
# Lock Acquisition
# acquire_lock in strict mode — a cycle is skipped rather than queued if the previous
# one is still running. At a 30-minute cadence, queuing would let a slow sync stack
# windows behind it.
#
# Host Detection
# detect_hosts() sets MY_ID and REMOTE_ID for routing and logs.
#
# Empty Job List Guard
# Exits with an error and a notification if CRITICAL_MAINTENANCE_SCRIPTS is empty —
# a silently empty critical tier would stop downloader resets and play-state sync
# while still reporting success every 30 minutes.
#
# Remote IP Resolution
# resolve_remote_ip confirms the partner is reachable before any transfer is attempted.
#
# RSYNC_ENABLED Gate
# The global kill switch is respected before any rsync call, so disabling rsync
# ecosystem-wide genuinely stops it here too.
#
# Non-Fatal Steps
# A failing job is recorded and the rest of the tier still runs.
#
# ==============================================================================================
# CONFIGURATION
@@ -98,6 +118,16 @@ fi
acquire_lock "strict"
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 [[ ${#CRITICAL_MAINTENANCE_SCRIPTS[@]} -eq 0 ]]; then
error "CRITICAL_MAINTENANCE_SCRIPTS is empty — no critical maintenance scripts will run"
error "Check CRITICAL_MAINTENANCE_SCRIPTS in master.conf"
notify "critical maintenance scripts skipped on $(hostname) ($MY_ID) — CRITICAL_MAINTENANCE_SCRIPTS is empty" \
"$(basename "$0" .sh)" "warning"
exit 1
fi
resolve_remote_ip
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no changes will be made"