Show Gateway UI button reliably: get token via openclaw config CLI; bump add-on to 0.5.9
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
name: OpenClaw Assistant
|
name: OpenClaw Assistant
|
||||||
version: "0.5.8"
|
version: "0.5.9"
|
||||||
slug: openclaw_assistant
|
slug: openclaw_assistant
|
||||||
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
||||||
url: https://github.com/techartdev/OpenClawHomeAssistant
|
url: https://github.com/techartdev/OpenClawHomeAssistant
|
||||||
|
|||||||
@@ -200,8 +200,9 @@ fi
|
|||||||
|
|
||||||
# Render nginx config from template.
|
# Render nginx config from template.
|
||||||
# The gateway token is NOT managed by the add-on; OpenClaw will generate/store it.
|
# 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.
|
# Best-effort: query it via CLI (works even if openclaw.json is JSON5). If unknown, we hide the button.
|
||||||
GW_PUBLIC_URL="$GW_PUBLIC_URL" python3 - <<'PY'
|
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
|
import os
|
||||||
from pathlib import Path
|
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()
|
landing_tpl = Path('/etc/nginx/landing.html.tpl').read_text()
|
||||||
public_url = os.environ.get('GW_PUBLIC_URL','')
|
public_url = os.environ.get('GW_PUBLIC_URL','')
|
||||||
|
|
||||||
# Best-effort: read token from OpenClaw config if it exists and is strict JSON.
|
# Token comes from environment (best-effort CLI query in run.sh)
|
||||||
# (If it's JSON5 or missing, we leave token empty and the landing page will guide the user.)
|
token = os.environ.get('GW_TOKEN','')
|
||||||
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 = ''
|
|
||||||
|
|
||||||
gw_path = '' if public_url.endswith('/') else '/'
|
gw_path = '' if public_url.endswith('/') else '/'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user