Files
hermes-arch-stack/libexec/hermes-stack-doctor
T
2026-09-05 22:47:35 +02:00

59 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Euo pipefail
CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/hermes-stack-maintenance/config.env"
failures=0
ok() { printf '✓ %s\n' "$*"; }
bad() { printf '✗ %s\n' "$*"; failures=$((failures + 1)); }
[[ -r "$CONFIG_FILE" ]] || {
bad "$CONFIG_FILE fehlt"
exit 1
}
# shellcheck disable=SC1090
source "$CONFIG_FILE"
for command in git curl jq tar zstd systemctl hermes; do
command -v "$command" >/dev/null 2>&1 && ok "$command vorhanden" || bad "$command fehlt"
done
for script in "$HOME/.local/libexec"/hermes-stack-*; do
[[ -f "$script" ]] || continue
bash -n "$script" && ok "Syntax: ${script##*/}" || bad "Syntaxfehler: ${script##*/}"
done
if [[ -d "$HERMES_REPO/.git" ]]; then
ok "Hermes-Git-Checkout vorhanden"
dirty="$(git -C "$HERMES_REPO" status --porcelain --untracked-files=all |
grep -vxF '?? .install_method' || true)"
[[ -z "$dirty" ]] && ok "Hermes-Checkout sauber" || bad "Hermes-Checkout enthält lokale Änderungen"
else
bad "Hermes-Git-Checkout fehlt"
fi
systemctl --user is-active --quiet "$GATEWAY_SERVICE" && ok "Gateway aktiv" || bad "Gateway inaktiv"
hermes gateway status >/dev/null 2>&1 && ok "Gateway gesund" || bad "Gateway-Status fehlgeschlagen"
if curl --fail --silent --max-time 5 "$LLAMA_URL/health" |
jq -e '.status == "ok"' >/dev/null 2>&1; then
ok "llama.cpp-Endpunkt gesund"
else
bad "llama.cpp-Endpunkt nicht gesund"
fi
set +u
set -a
# shellcheck disable=SC1090
source "$HERMES_ENV" 2>/dev/null || true
set +a
set -u
if [[ -n "${SIGNAL_HTTP_URL:-}" ]]; then
status="$(curl --silent --output /dev/null --max-time 5 --write-out '%{http_code}' \
"${SIGNAL_HTTP_URL%/}/api/v1/check" || true)"
[[ "$status" =~ ^2[0-9][0-9]$ ]] && ok "signal-cli HTTP erreichbar" || bad "signal-cli HTTP nicht erreichbar"
fi
printf '\nFehler: %d\n' "$failures"
((failures == 0))