Red tests first. - tests/homepage_deploy.bats: the deploy ships the homepage (assets to /srv/homepage, the checker timer, both Caddy hashes, deployed.js) and is git-driven (pulls main); the checker runs as a systemd timer. - scripts/homepage-status.service / .timer: the checker as a oneshot service + a 3-minute timer (Q2/Q35). - scripts/deploy.sh: the Caddyfile render now substitutes BOTH hashes (REPLACE_WITH_HASH <- CADDY_BASICAUTH_HASH, REPLACE_WITH_ADMIN_HASH <- CADDY_ADMIN_HASH). A new homepage step copies the assets to /srv/homepage, generates deployed.js from the deployed commit's datetime (Q43), installs the checker timer, and runs the checker once so status.json exists at once. - tests/llm_units.bats: scoped the three LLM-unit tests to frank-default-*.service (the homepage unit is a different pattern: it installs to /usr/local/bin and runs from /srv at deploy time).
83 lines
3.1 KiB
Bash
83 lines
3.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Seam: LLM systemd unit integrity.
|
|
# Every LLM unit (frank-default-*.service) must point at files that exist in
|
|
# this repo. The homepage-status unit is a different pattern (it installs to
|
|
# /usr/local/bin and runs from /srv at deploy time) and is not checked here.
|
|
# The units reference absolute paths on the target checkout
|
|
# (/home/dank/serverAppConfigs/...); the relative part of each path must
|
|
# resolve to a tracked file here. A unit that points at a retired checkout
|
|
# path (the old vllmScripts layout) fails this seam.
|
|
|
|
load helpers
|
|
|
|
TARGET_DIR="/home/dank/serverAppConfigs"
|
|
|
|
# unit_repo_path <unit-file> — for each absolute path in the unit's
|
|
# ExecStart and Environment lines, print the repo-relative path if it is
|
|
# rooted at $TARGET_DIR, or "MISSING:<abs>" if the relative file does not
|
|
# exist in the repo, or "FOREIGN:<abs>" if it is rooted elsewhere.
|
|
unit_repo_path() {
|
|
local unit="$1"
|
|
local line path rel
|
|
while IFS= read -r line; do
|
|
path="${line#*=}"
|
|
path="${path#Environment=\"}"
|
|
path="${path%\"}"
|
|
# keep only the value after the last '=' for VAR=/abs/path pairs
|
|
if [[ "$path" == *=* && "$path" != "$TARGET_DIR"* ]]; then
|
|
path="${path##*=}"
|
|
fi
|
|
if [[ "$path" == "$TARGET_DIR"/* ]]; then
|
|
rel="${path#"$TARGET_DIR"/}"
|
|
if [ -e "$REPO_ROOT/$rel" ]; then
|
|
printf 'OK\n'
|
|
else
|
|
printf 'MISSING:%s\n' "$path"
|
|
fi
|
|
else
|
|
printf 'FOREIGN:%s\n' "$path"
|
|
fi
|
|
done < <(grep -E '^(ExecStart=|Environment=)' "$unit")
|
|
}
|
|
|
|
@test "every LLM unit points at the merged repo checkout" {
|
|
local any=0 unit bad
|
|
while IFS= read -r unit; do
|
|
any=1
|
|
bad=$(unit_repo_path "$unit" | grep -v '^OK$' || true)
|
|
if [ -n "$bad" ]; then
|
|
echo "unit $(basename "$unit") has bad paths:"
|
|
echo "$bad"
|
|
return 1
|
|
fi
|
|
done < <(find "$REPO_ROOT/scripts" -name 'frank-default-*.service' -type f | sort)
|
|
[ "$any" -eq 1 ] || skip "no LLM units yet"
|
|
}
|
|
|
|
@test "every LLM unit references an env file that exists in the repo" {
|
|
local unit envfile
|
|
while IFS= read -r unit; do
|
|
envfile=$(grep -oE 'Environment="[^"]*ENV_FILE=[^"]*"' "$unit" \
|
|
| head -1 | sed -E 's/Environment="[^=]*=//; s/"$//')
|
|
[ -n "$envfile" ] || continue
|
|
local rel="${envfile#"$TARGET_DIR"/}"
|
|
[ -f "$REPO_ROOT/$rel" ] || {
|
|
echo "unit $(basename "$unit") env file $envfile not in repo"
|
|
return 1
|
|
}
|
|
done < <(find "$REPO_ROOT/scripts" -name 'frank-default-*.service' -type f | sort)
|
|
}
|
|
|
|
@test "LLM serve scripts exist for every unit" {
|
|
local unit svc script
|
|
while IFS= read -r unit; do
|
|
svc=$(basename "$unit" .service)
|
|
script=$(grep -E '^ExecStart=' "$unit" | head -1 | sed 's/^ExecStart=//')
|
|
local rel="${script#"$TARGET_DIR"/}"
|
|
[ -f "$REPO_ROOT/$rel" ] || {
|
|
echo "unit $svc: ExecStart script $script not in repo"
|
|
return 1
|
|
}
|
|
done < <(find "$REPO_ROOT/scripts" -name 'frank-default-*.service' -type f | sort)
|
|
}
|