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
+32 -5
View File
@@ -40,11 +40,28 @@
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Root check — all stop scripts require root
# acquire_lock — prevents concurrent array stop runs
# detect_hosts() — MY_ID in notifications and logs
# platform_require_cmd — notify validated before use
# notify on failures — alert if any stop script fails
# Root Enforcement
# Every stop script launched here requires root.
#
# Lock Acquisition
# acquire_lock prevents concurrent array stop runs. Two overlapping shutdown
# sequences would fight over the same containers.
#
# Host Detection
# detect_hosts() sets MY_ID for notifications and logs.
#
# Empty Job List Guard
# Exits with an error and a notification if ARRAY_STOP_SCRIPTS is empty. An empty
# list means the array stops without saving the conf cache or gracefully stopping
# containers — the failure would only be discovered at the next boot.
#
# Non-Fatal Steps
# A failing stop script is recorded and the remaining ones still run. Abandoning the
# shutdown sequence partway would leave more state unsaved than continuing does.
#
# Failure Notification
# Any failing stop script raises a notification. Shutdown is unattended and its
# failures are invisible until they cause a problem on the way back up.
#
# ==============================================================================================
# CONFIGURATION
@@ -97,6 +114,16 @@ 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 [[ ${#ARRAY_STOP_SCRIPTS[@]} -eq 0 ]]; then
error "ARRAY_STOP_SCRIPTS is empty — no array stop scripts will run"
error "Check ARRAY_STOP_SCRIPTS in master.conf"
notify "array stop scripts skipped on $(hostname) ($MY_ID) — ARRAY_STOP_SCRIPTS is empty" \
"$(basename "$0" .sh)" "warning"
exit 1
fi
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no stop scripts will be executed"
# ==============================================================================================