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:
@@ -55,13 +55,33 @@
|
||||
# OPERATIONAL SAFEGUARDS
|
||||
# ==============================================================================================
|
||||
#
|
||||
# Root check — all launched scripts require root
|
||||
# acquire_lock — prevents duplicate array start launches
|
||||
# detect_hosts() — MY_ID in notifications
|
||||
# platform_require_cmd — notify validated before use
|
||||
# chmod +x auto-fix — non-executable scripts fixed before launch
|
||||
# Full path on failure — shows exact path for debugging
|
||||
# notify on failures — alert if any script fails to launch
|
||||
# Root Enforcement
|
||||
# Every script launched here requires root.
|
||||
#
|
||||
# Lock Acquisition
|
||||
# acquire_lock prevents duplicate array start launches. Unraid can fire the array
|
||||
# start hook more than once, and a second pass would re-launch continuous scripts
|
||||
# that are already running.
|
||||
#
|
||||
# Host Detection
|
||||
# detect_hosts() sets MY_ID for notifications.
|
||||
#
|
||||
# Empty Job List Guard
|
||||
# Exits with an error and a notification if ARRAY_START_SCRIPTS is empty. An empty
|
||||
# list would silently bring the array up with no ramdisk, no network setup, no
|
||||
# watchdogs and no fallback — while reporting a clean start.
|
||||
#
|
||||
# Executable Auto-Fix
|
||||
# Non-executable scripts are chmod +x'd before launch. A permission bit lost to a
|
||||
# git checkout or a file copy should not silently disable a boot-time component.
|
||||
#
|
||||
# Full Path on Failure
|
||||
# Failures report the exact resolved path, so a missing script is immediately
|
||||
# distinguishable from a script that ran and failed.
|
||||
#
|
||||
# Failure Notification
|
||||
# Any script that fails to launch raises a notification — array start is unattended,
|
||||
# so a silent failure here would only surface much later as a missing service.
|
||||
#
|
||||
# ==============================================================================================
|
||||
# CONFIGURATION
|
||||
@@ -109,6 +129,16 @@ 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 [[ ${#ARRAY_START_SCRIPTS[@]} -eq 0 ]]; then
|
||||
error "ARRAY_START_SCRIPTS is empty — no array start scripts will run"
|
||||
error "Check ARRAY_START_SCRIPTS in master.conf"
|
||||
notify "array start scripts skipped on $(hostname) ($MY_ID) — ARRAY_START_SCRIPTS is empty" \
|
||||
"$(basename "$0" .sh)" "warning"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — scripts will not be launched"
|
||||
|
||||
# ==============================================================================================
|
||||
|
||||
Reference in New Issue
Block a user