deploy: feature flags, --diff, tolerate failed restarts
Li3, NVMe watchdog, Home Assistant/ESPHome, Frigate and Cockpit are installed, enabled and restarted only when their ENABLE_* flag is 1. --diff shows what would change in /etc. A unit that fails to restart is recorded as a warning instead of aborting the deploy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,4 +69,32 @@ else
|
||||
ok "van: unmanaged-devices has no eth0"
|
||||
fi
|
||||
|
||||
# 6. flagged units/paths only appear inside their ENABLE_* guard in deploy.sh.
|
||||
# Convention: guards are column-0 `if [ "$ENABLE_X" = 1 ]; then` ... `fi`,
|
||||
# contents indented (so a nested `fi` never sits in column 0).
|
||||
if awk '
|
||||
BEGIN {
|
||||
need["van-li3-battery"]="ENABLE_LI3"
|
||||
need["van-nvme-watch"]="ENABLE_NVME_WATCH"
|
||||
need["nvme-watch-config"]="ENABLE_NVME_WATCH"
|
||||
need["homeassistant"]="ENABLE_HA"
|
||||
need["esphome"]="ENABLE_HA"
|
||||
need["frigate"]="ENABLE_FRIGATE"
|
||||
need["cockpit"]="ENABLE_COCKPIT"
|
||||
}
|
||||
/^if \[ "\$ENABLE_[A-Z0-9_]+" = 1 \]/ { match($0, /ENABLE_[A-Z0-9_]+/); guard=substr($0, RSTART, RLENGTH); next }
|
||||
/^fi([[:space:]]|$)/ { guard=""; next }
|
||||
/^[[:space:]]*(#|echo)/ { next }
|
||||
{ for (u in need) if (index($0, u) && guard != need[u]) {
|
||||
printf " deploy.sh:%d mentions %s outside an %s guard: %s\n", NR, u, need[u], $0; bad=1 } }
|
||||
END { exit bad }
|
||||
' deploy.sh; then ok "flagged units are only touched inside their ENABLE_* guard"; else bad "flag gating"; fi
|
||||
|
||||
# 8. ./deploy.sh --diff runs (no root) and lists rendered files
|
||||
if out=$(./deploy.sh --diff hosts/van.conf 2>&1) && echo "$out" | grep -qE '^(NEW|CHANGED) '; then
|
||||
ok "deploy.sh --diff hosts/van.conf"
|
||||
else
|
||||
bad "deploy.sh --diff hosts/van.conf"; echo "$out" | sed 's/^/ /'
|
||||
fi
|
||||
|
||||
exit "$fail"
|
||||
|
||||
Reference in New Issue
Block a user