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
+40 -7
View File
@@ -40,13 +40,36 @@
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Root check — scripts called here require root
# acquire_lock — prevents concurrent intermediate windows
# detect_hosts() — aliases correct per-host share lists
# check_connectivity — verified before any rsync (skipped if no shares)
# check_remote_rootfs — aborts rsync if remote rootfs nearly full
# Non-fatal jobs — a failed arr_sync warns but does not block rsync or artwork fetch
# Minimal on success — runs 6x/day; full breakdown only on failure or --log
# Root Enforcement
# Every script called from here requires root.
#
# Lock Acquisition
# acquire_lock prevents concurrent intermediate windows.
#
# Host Detection
# detect_hosts() aliases the correct per-host share lists.
#
# Empty Job List Guard
# Exits with an error and a notification if INTERMEDIATE_MAINTENANCE_SCRIPTS is empty,
# rather than running six no-op windows a day that all report success.
#
# Connectivity Check
# check_connectivity is verified before any rsync, and skipped entirely when no shares
# are configured — there is nothing to reach a partner for.
#
# Remote Rootfs Check
# check_remote_rootfs aborts rsync if the remote rootfs is nearly full.
#
# Drive Temperature Escalation
# rsync.sh's exit code is honoured per share: exit 1 skips that share, exit 2 aborts
# every remaining sync in the window and notifies.
#
# Non-Fatal Jobs
# A failing arr_sync warns but does not block rsync or the artwork fetch that follow it.
#
# Minimal on Success
# Runs six times a day, so the full breakdown only prints on failure or with --log.
# A quiet run is the normal outcome and should not fill the log.
#
# ==============================================================================================
# CONFIGURATION
@@ -101,6 +124,16 @@ fi
acquire_lock
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 [[ ${#INTERMEDIATE_MAINTENANCE_SCRIPTS[@]} -eq 0 ]]; then
error "INTERMEDIATE_MAINTENANCE_SCRIPTS is empty — no intermediate maintenance scripts will run"
error "Check INTERMEDIATE_MAINTENANCE_SCRIPTS in master.conf"
notify "intermediate maintenance scripts skipped on $(hostname) ($MY_ID) — INTERMEDIATE_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"