From cabc5a79f78664faf27279ef5d01870b84ec71eb Mon Sep 17 00:00:00 2001 From: root Date: Sat, 31 Jan 2026 01:26:33 +0200 Subject: [PATCH] Show Gateway UI button reliably: get token via openclaw config CLI; bump add-on to 0.5.9 --- openclaw_assistant/config.yaml | 2 +- openclaw_assistant/run.sh | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/openclaw_assistant/config.yaml b/openclaw_assistant/config.yaml index 1add817..23c254f 100644 --- a/openclaw_assistant/config.yaml +++ b/openclaw_assistant/config.yaml @@ -1,5 +1,5 @@ name: OpenClaw Assistant -version: "0.5.8" +version: "0.5.9" slug: openclaw_assistant description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on. url: https://github.com/techartdev/OpenClawHomeAssistant diff --git a/openclaw_assistant/run.sh b/openclaw_assistant/run.sh index 5a7ddbe..801d05e 100644 --- a/openclaw_assistant/run.sh +++ b/openclaw_assistant/run.sh @@ -200,8 +200,9 @@ fi # Render nginx config from template. # The gateway token is NOT managed by the add-on; OpenClaw will generate/store it. -# If we don't know it yet, the landing page will show a hint instead of a broken link. -GW_PUBLIC_URL="$GW_PUBLIC_URL" python3 - <<'PY' +# Best-effort: query it via CLI (works even if openclaw.json is JSON5). If unknown, we hide the button. +GW_TOKEN="$(timeout 2s openclaw config get gateway.auth.token 2>/dev/null | tr -d '\n' || true)" +GW_PUBLIC_URL="$GW_PUBLIC_URL" GW_TOKEN="$GW_TOKEN" python3 - <<'PY' import os from pathlib import Path @@ -209,17 +210,8 @@ tpl = Path('/etc/nginx/nginx.conf.tpl').read_text() landing_tpl = Path('/etc/nginx/landing.html.tpl').read_text() public_url = os.environ.get('GW_PUBLIC_URL','') -# Best-effort: read token from OpenClaw config if it exists and is strict JSON. -# (If it's JSON5 or missing, we leave token empty and the landing page will guide the user.) -token = '' -try: - cfg_path = Path('/config/.openclaw/openclaw.json') - if cfg_path.exists(): - import json - cfg = json.loads(cfg_path.read_text(encoding='utf-8')) - token = (((cfg.get('gateway') or {}).get('auth') or {}).get('token')) or '' -except Exception: - token = '' +# Token comes from environment (best-effort CLI query in run.sh) +token = os.environ.get('GW_TOKEN','') gw_path = '' if public_url.endswith('/') else '/'