mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 05:37:19 +01:00
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
88 lines
2.8 KiB
Bash
Executable File
88 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# install-runtime-conformance.sh — run the runtime conformance audit on the box
|
|
# and alert to Telegram, per finding, on transition.
|
|
#
|
|
# The audit itself ships in the repo (scripts/ci/runtime-conformance-audit.sh)
|
|
# and the deploy rsyncs it to /opt/loki/app, so there is ONE copy. This
|
|
# installs only the wrapper and the timer.
|
|
#
|
|
# Per-FINDING alert keys, never one aggregate: host-check spent six weeks unable
|
|
# to fire because a single permanently-failed unit pinned one boolean at `bad`.
|
|
# A new finding must always transition, whatever else is already broken.
|
|
#
|
|
# Idempotent. Usage: bash scripts/hetzner/install-runtime-conformance.sh
|
|
set -euo pipefail
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
|
|
ssh -o BatchMode=yes "$BOX" 'sudo bash -s' <<'REMOTE'
|
|
set -euo pipefail
|
|
MON=/opt/monitoring
|
|
mkdir -p "$MON/state"
|
|
|
|
cat > "$MON/runtime-conformance.sh" <<'CHK'
|
|
#!/usr/bin/env bash
|
|
# Wrapper: run the audit, alert per finding. Invoked by the timer.
|
|
#
|
|
# NOT `set -e`: the audit exits non-zero precisely when it has something to say,
|
|
# and -e would kill this before it could say it.
|
|
set -u
|
|
MON="${MON:-/opt/monitoring}"
|
|
. "$MON/lib-alert.sh"
|
|
AUDIT=/opt/loki/app/scripts/ci/runtime-conformance-audit.sh
|
|
|
|
# "Could not look" gets its OWN key so it can never overwrite a real finding
|
|
# or be mistaken for a clean run.
|
|
if [ ! -r "$AUDIT" ]; then
|
|
alert_transition rtc_probe bad "🔎" "Runtime conformance CANNOT RUN: $AUDIT missing (deploy changed?)"
|
|
exit 0
|
|
fi
|
|
alert_transition rtc_probe ok "🔎" ""
|
|
|
|
out=$(bash "$AUDIT" 2>&1)
|
|
|
|
# One key per app+check, so a new finding always transitions.
|
|
declare -A seen=()
|
|
while IFS='|' read -r kind app msg; do
|
|
[ "$kind" = "FINDING" ] || continue
|
|
key="rtc_$(printf '%s' "$app $msg" | tr -c 'a-zA-Z0-9' '_' | cut -c1-60)"
|
|
seen[$key]=1
|
|
alert_transition "$key" bad "🧩" "$app: $msg"
|
|
done <<< "$out"
|
|
|
|
# A finding that has gone away clears its own key, or its next occurrence
|
|
# would be silent.
|
|
for sf in "$MON"/state/host_rtc_*; do
|
|
[ -e "$sf" ] || continue
|
|
k=$(basename "$sf"); k=${k#host_}
|
|
case "$k" in rtc_probe) continue ;; esac
|
|
[ -n "${seen[$k]:-}" ] || alert_transition "$k" ok "" ""
|
|
done
|
|
exit 0
|
|
CHK
|
|
chmod +x "$MON/runtime-conformance.sh"
|
|
|
|
cat > /etc/systemd/system/loki-runtime-conformance.service <<'SVC'
|
|
[Unit]
|
|
Description=Runtime conformance audit (what is deployed, not what is committed)
|
|
OnFailure=notify-failure@%n.service
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/opt/monitoring/runtime-conformance.sh
|
|
SVC
|
|
|
|
cat > /etc/systemd/system/loki-runtime-conformance.timer <<'TMR'
|
|
[Unit]
|
|
Description=Run the runtime conformance audit every 6h
|
|
[Timer]
|
|
OnCalendar=*-*-* 02,08,14,20:00:00
|
|
RandomizedDelaySec=300
|
|
Persistent=true
|
|
[Install]
|
|
WantedBy=timers.target
|
|
TMR
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable --now loki-runtime-conformance.timer >/dev/null
|
|
systemctl list-timers --all --no-pager | grep runtime-conformance || true
|
|
REMOTE
|