From 8ef079d40e9c1618b92209ca2ef28f2ea9ade174 Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:15:15 +0200 Subject: [PATCH] Fail closed when Hermes local config is unreadable --- compose.yaml | 3 ++- docs/CURRENT_REFERENCE.md | 2 ++ docs/INSTALLATION.md | 4 ++++ platform/hermes/install-hermes.sh | 1 + platform/hermes/start-hermes-managed.sh | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 platform/hermes/start-hermes-managed.sh diff --git a/compose.yaml b/compose.yaml index c0e8cdb..ddab671 100644 --- a/compose.yaml +++ b/compose.yaml @@ -788,12 +788,13 @@ services: image: ${HERMES_IMAGE:-nousresearch/hermes-agent@sha256:143bdb9086bb2db645346179f11091e621ef6b7f4f9e5049ae7454bfeb3a0495} container_name: mike-ai-hermes restart: unless-stopped - command: [gateway, run] + command: [/usr/local/bin/start-hermes-managed] env_file: - /data/hermes/.env volumes: - /data/hermes:/opt/data - /data/hermes/workspace:/workspace + - ./platform/hermes/start-hermes-managed.sh:/usr/local/bin/start-hermes-managed:ro environment: HERMES_HOME: /opt/data dns: ["${AI_DNS:-1.1.1.1}"] diff --git a/docs/CURRENT_REFERENCE.md b/docs/CURRENT_REFERENCE.md index ffbc3ac..aca8fe3 100644 --- a/docs/CURRENT_REFERENCE.md +++ b/docs/CURRENT_REFERENCE.md @@ -96,6 +96,8 @@ Der Router übernimmt: Assistant, ARR, Navidrome und ein gemeinsamer MUA-Unraid-Zugang - kein Docker-Socket, kein Host-Root-Mount und keine Veröffentlichung auf der Universitätsadresse +- Start verweigert, wenn die verwaltete Konfiguration nicht lesbar ist oder + nicht ausdrücklich `custom` und den lokalen Router als Provider nennt ## Vision diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index decd38c..13af1d0 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -90,6 +90,10 @@ Der Schlüssel der Agent-API liegt entsprechend unter `/etc/mike-ai/hermes-api-key`. Beide Werte gehören weder in Git noch in Chats. Hermes' lokales Terminal sieht nur `/data/hermes/workspace` im Container. Für Athena und Unraid verwendet es die dokumentierten Operator-/MUA-MCPs. +Ein Startwächter beendet den Container absichtlich, falls diese verwaltete +Konfiguration nicht lesbar ist oder auf einen anderen Provider als den lokalen +Router zeigt. Dadurch darf ein Rechtefehler nicht auf Hermes' Cloud-Standard +zurückfallen. Der SSH-Fallback lauscht ausschließlich auf der IPv4-Adresse von `wg0` im WireGuard-Gateway-Container. Er wird nicht als Docker-Port auf dem diff --git a/platform/hermes/install-hermes.sh b/platform/hermes/install-hermes.sh index 59ba367..c1bafac 100755 --- a/platform/hermes/install-hermes.sh +++ b/platform/hermes/install-hermes.sh @@ -55,4 +55,5 @@ if [[ -s $HERMES_DATA_DIR/config.yaml ]] && \ "$HERMES_DATA_DIR/config.yaml.before-managed-update-$(date +%Y%m%d-%H%M%S)" fi install -m 0600 "$STACK_DIR/platform/hermes/config.yaml" "$HERMES_DATA_DIR/config.yaml" +chown -R 10000:10000 "$HERMES_DATA_DIR" printf 'HERMES_CONFIG_OK %s\n' "$HERMES_DATA_DIR" diff --git a/platform/hermes/start-hermes-managed.sh b/platform/hermes/start-hermes-managed.sh new file mode 100755 index 0000000..c976b71 --- /dev/null +++ b/platform/hermes/start-hermes-managed.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +set -eu + +config=/opt/data/config.yaml +if [ ! -r "$config" ]; then + echo "HERMES_START_REFUSED: managed config is not readable" >&2 + exit 78 +fi +grep -Eq '^[[:space:]]+provider:[[:space:]]+["'\'']?custom["'\'']?[[:space:]]*$' "$config" || { + echo "HERMES_START_REFUSED: provider is not custom" >&2 + exit 78 +} +grep -Eq '^[[:space:]]+base_url:[[:space:]]+["'\'']?http://router:8081/v1["'\'']?[[:space:]]*$' "$config" || { + echo "HERMES_START_REFUSED: local router URL is missing" >&2 + exit 78 +} + +exec hermes gateway run +