chore: anchor the scripts ignore rule and keep the guard verifier (T48)
.gitignore had `scripts` as an unanchored pattern. A pattern without a slash
matches a directory of that name at ANY depth, so a future
modules/*/scripts/ would have been silently ignored — the kind of thing that
only shows up as "why is my file not in git". It is anchored to /scripts/
now. No tracked file was matched before or after (verified with
`git ls-files | git check-ignore --stdin --no-index`, empty both ways).
The 22 scripts in .temp/ are not committed wholesale: they are eight
iterations of one T4 test (t4-final-v5..v8), three of another
(t4-live-test{,v2,v3}), plus one-shot deploy/cleanup/diagnose scripts that
hardcode `cd /mnt/s/Git/nixos` and perform umount / mount --move. Committing
them would be noise, not knowledge.
One of them is reusable and non-destructive, so it is preserved:
.ci/verify/guard-non-destructive-verify.sh. It creates two throwaway systemd
units (ConditionPathIsMountPoint=/nonexistent must refuse to start,
=/mnt/services must start) and resets them, so it can be run against a live
host to prove the condition is evaluated at all. That is the check the owner
needs for T52. Content is byte-identical to the .temp original
(md5 b0ac8081aae568a3db921fb64f4c0a05) and passes shellcheck -S error.
Not pushed.
This commit is contained in:
1 parent
0d52f2058d
commit
2ed525b9f5
2 files changed
+58
-1
No files matched your search
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Non-destructive verification of ConditionPathIsMountPoint guard logic.
|
||||
# Creates two test systemd units:
|
||||
# 1. ConditionPathIsMountPoint=/nonexistent — should FAIL to start
|
||||
# 2. ConditionPathIsMountPoint=/mnt/services — should SUCCEED (real mount)
|
||||
# Proves the guard condition is evaluated correctly by systemd.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
echo "=== postgresql guard in runtime (real production unit) ==="
|
||||
systemctl show postgresql -p ConditionPathIsMountPoint -p RequiresMountsFor
|
||||
echo
|
||||
|
||||
echo "=== Test 1: ConditionPathIsMountPoint=/nonexistent (should FAIL) ==="
|
||||
sudo systemd-run \
|
||||
--unit=test-guard-nonexistent \
|
||||
--property=ConditionPathIsMountPoint=/nonexistent/path/does/not/exist \
|
||||
--property=Type=oneshot \
|
||||
--property=ExecStart=/bin/true \
|
||||
--no-block 2>&1
|
||||
sleep 1
|
||||
STATE1=$(systemctl is-active test-guard-nonexistent 2>&1)
|
||||
echo " is-active: $STATE1"
|
||||
JOURNAL1=$(journalctl -u test-guard-nonexistent -n 5 --no-pager 2>&1 | grep -iE "condition|failed|skipped" | head -3)
|
||||
echo " journal: $JOURNAL1"
|
||||
sudo systemctl reset-failed test-guard-nonexistent 2>/dev/null || true
|
||||
echo
|
||||
|
||||
echo "=== Test 2: ConditionPathIsMountPoint=/mnt/services (should PASS) ==="
|
||||
sudo systemd-run \
|
||||
--unit=test-guard-real \
|
||||
--property=ConditionPathIsMountPoint=/mnt/services \
|
||||
--property=Type=oneshot \
|
||||
--property=ExecStart=/bin/true \
|
||||
--no-block 2>&1
|
||||
sleep 1
|
||||
STATE2=$(systemctl is-active test-guard-real 2>&1)
|
||||
echo " is-active: $STATE2"
|
||||
JOURNAL2=$(journalctl -u test-guard-real -n 5 --no-pager 2>&1 | grep -iE "condition|started|active" | head -3)
|
||||
echo " journal: $JOURNAL2"
|
||||
sudo systemctl reset-failed test-guard-real 2>/dev/null || true
|
||||
echo
|
||||
|
||||
echo "=== Verdict ==="
|
||||
if [ "$STATE1" = "inactive" ] || [ "$STATE1" = "failed" ]; then
|
||||
echo " Test 1 (nonexistent path): CORRECT — unit refused to start (condition false)"
|
||||
else
|
||||
echo " Test 1 (nonexistent path): UNEXPECTED — unit started despite condition"
|
||||
fi
|
||||
if [ "$STATE2" = "active" ] || [ "$STATE2" = "activating" ]; then
|
||||
echo " Test 2 (real mount /mnt/services): CORRECT — unit started (condition true)"
|
||||
else
|
||||
echo " Test 2 (real mount /mnt/services): UNEXPECTED — unit did not start"
|
||||
fi
|
||||
Reference in new issue
Block a user