fix: resolve shutdown-schedule canonical path via guardctl dynamically
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run

Hardcoding /usr/local/share/locked-shutdown-schedule.conf broke once the
hosts/shutdown-schedule file-guard instances moved to guard-lib's own
canonical-path layout. Resolve it at runtime via `guardctl file-guard
canonical-path` instead, and fail loudly if the guard-lib instance isn't
installed rather than silently reading/writing the wrong path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFNiYQQgSLAkiBXswyimPq
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-07-04 11:48:39 +02:00
parent e25d806742
commit edd11d4312

View File

@ -13,7 +13,13 @@
set -euo pipefail
CONFIG_FILE="/etc/shutdown-schedule.conf"
CANONICAL_FILE="/usr/local/share/locked-shutdown-schedule.conf"
GUARD_NAME="shutdown-schedule"
CANONICAL_FILE="$(guardctl file-guard canonical-path "$GUARD_NAME" 2>/dev/null || true)"
if [[ -z "$CANONICAL_FILE" ]]; then
echo "Error: guard-lib instance '$GUARD_NAME' is not installed (guardctl file-guard canonical-path returned empty)" >&2
exit 1
fi
# Check for --restore flag
RESTORE_MODE=false