fix: provision config.yaml/.env + systemd EnvironmentFile drop-in

Fixes #9 (custom_providers missing — fresh installs had no config.yaml/.env,
so gateway had no provider to connect to) and #10 (systemd unit had no
EnvironmentFile, so gateway couldn't read rocketchat.env/.env → crash-loop).

Templates provisioned on first install only (no overwrites):
- templates/config.yaml: minimal working config with ollama-cloud provider
- templates/.env: API key placeholder
- templates/hermes-gateway-env.conf: systemd drop-in wiring rocketchat.env + .env
This commit is contained in:
Hermes Agent
2026-06-03 12:24:08 +02:00
parent bb8623aed5
commit f54f90be5b
4 changed files with 83 additions and 1 deletions
+36 -1
View File
@@ -42,6 +42,9 @@ load_lang() {
[copying]="📁 Copying plugin files…"
[env_written]="🔑 Credentials written to %s"
[config_updated]="⚙️ config.yaml updated"
[config_provisioned]="📄 Provisioned minimal config.yaml"
[env_provisioned]="🔧 Provisioned .env template"
[env_dropin]="🔌 Systemd EnvironmentFile drop-in installed"
[copied]="📁 Copied %d plugin files"
[ollama_check]="🔍 Checking Ollama..."
[ollama_missing]="⚠️ Ollama not found. Install: curl -fsSL https://ollama.com/install.sh | sh"
@@ -85,6 +88,9 @@ load_lang() {
[copying]="📁 Kopiere Plugin-Dateien…"
[env_written]="🔑 Zugangsdaten gespeichert in %s"
[config_updated]="⚙️ config.yaml aktualisiert"
[config_provisioned]="📄 Minimale config.yaml bereitgestellt"
[env_provisioned]="🔧 .env-Vorlage bereitgestellt"
[env_dropin]="🔌 Systemd EnvironmentFile-Drop-in installiert"
[copied]="📁 %d Plugin-Dateien kopiert"
[ollama_check]="🔍 Prüfe Ollama..."
[ollama_missing]="⚠️ Ollama nicht gefunden. Installation: curl -fsSL https://ollama.com/install.sh | sh"
@@ -419,8 +425,26 @@ if [ -d "$SCRIPT_DIR/plugin" ]; then
msg copied "$copied_count"
fi
# ─── Fix #9: Provision minimal config.yaml + .env ──────────
# Only when hermes has NO config yet (fresh install, no setup run)
HERMES_HOME="$HOME/.hermes"
CONFIG="$HERMES_HOME/config.yaml"
ENVFILE="$HERMES_HOME/.env"
if [ ! -f "$CONFIG" ]; then
mkdir -p "$HERMES_HOME"
if [ -f "$SCRIPT_DIR/templates/config.yaml" ]; then
cp "$SCRIPT_DIR/templates/config.yaml" "$CONFIG"
msg config_provisioned
fi
fi
if [ ! -f "$ENVFILE" ] && [ -f "$SCRIPT_DIR/templates/.env" ]; then
cp "$SCRIPT_DIR/templates/.env" "$ENVFILE"
chmod 600 "$ENVFILE"
msg env_provisioned
fi
# ─── Patch config.yaml ────────────────────────────────────
CONFIG="$HOME/.hermes/config.yaml"
if [ -f "$CONFIG" ]; then
# Ensure rocketchat-platform is in plugins.enabled
if ! grep -q 'rocketchat-platform' "$CONFIG" 2>/dev/null; then
@@ -450,6 +474,17 @@ fi
# Install / refresh systemd user service
$PYTHON -m hermes_cli.main gateway install 2>/dev/null || true
# ─── Fix #10: systemd EnvironmentFile drop-in ─────────────
# Gateway needs rocketchat.env + .env — hermes gateway install
# does not wire them automatically.
DROPDIN_DIR="$HOME/.config/systemd/user/hermes-gateway.service.d"
DROPDIN_FILE="$DROPDIN_DIR/env.conf"
mkdir -p "$DROPDIN_DIR"
if [ -f "$SCRIPT_DIR/templates/hermes-gateway-env.conf" ]; then
cp "$SCRIPT_DIR/templates/hermes-gateway-env.conf" "$DROPDIN_FILE"
msg env_dropin
fi
# Ensure lingering is enabled (may need sudo — best-effort)
loginctl enable-linger 2>/dev/null || true