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:
@@ -39,12 +39,33 @@
|
||||
# OPERATIONAL SAFEGUARDS
|
||||
# ==============================================================================================
|
||||
#
|
||||
# Root check — required for the docker/system reads used in the report
|
||||
# acquire_lock — prevents overlapping weekly runs
|
||||
# detect_hosts() — MY_ID in banner and summary
|
||||
# Non-fatal steps — a failed script is logged; remaining scripts still run
|
||||
# Flag pass-through — --dry-run and --log forwarded to all child scripts
|
||||
# notify() on failure — pushed only outside --dry-run, matching the runtime-mode contract below
|
||||
# Root Enforcement
|
||||
# Required for the docker and system reads the report is built from.
|
||||
#
|
||||
# Lock Acquisition
|
||||
# acquire_lock prevents overlapping weekly runs.
|
||||
#
|
||||
# Host Detection
|
||||
# detect_hosts() sets MY_ID for the banner and summary.
|
||||
#
|
||||
# Empty Job List Guard
|
||||
# Exits with an error and a notification if COFFEE_REPORT_SCRIPTS is empty. A report
|
||||
# that silently contains nothing still arrives looking like a report.
|
||||
#
|
||||
# Read-Only by Composition
|
||||
# Every child here is a reporting script. This orchestrator changes nothing itself —
|
||||
# it only sequences reads and assembles their output.
|
||||
#
|
||||
# Non-Fatal Steps
|
||||
# A failing script is logged and the remaining ones still run, so one unavailable
|
||||
# subsystem costs a section of the report rather than the whole thing.
|
||||
#
|
||||
# Flag Pass-Through
|
||||
# --dry-run and --log are forwarded to every child script.
|
||||
#
|
||||
# Notification Contract
|
||||
# notify() fires on failure only outside --dry-run, matching the runtime-mode contract
|
||||
# below — a dry run never sends anything outward.
|
||||
#
|
||||
# ==============================================================================================
|
||||
# CONFIGURATION
|
||||
@@ -91,6 +112,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 [[ ${#COFFEE_REPORT_SCRIPTS[@]} -eq 0 ]]; then
|
||||
error "COFFEE_REPORT_SCRIPTS is empty — no coffee report scripts will run"
|
||||
error "Check COFFEE_REPORT_SCRIPTS in master.conf"
|
||||
notify "coffee report scripts skipped on $(hostname) ($MY_ID) — COFFEE_REPORT_SCRIPTS is empty" \
|
||||
"$(basename "$0" .sh)" "warning"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ==============================================================================================
|
||||
# ━━━ Helpers ━━━
|
||||
# ==============================================================================================
|
||||
|
||||
Reference in New Issue
Block a user