Fix nginx quoting: serve landing page from file; bump add-on to 0.5.6
This commit is contained in:
@@ -48,6 +48,7 @@ RUN npm config set fund false && npm config set audit false \
|
|||||||
|
|
||||||
COPY run.sh /run.sh
|
COPY run.sh /run.sh
|
||||||
COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl
|
COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl
|
||||||
|
COPY landing.html.tpl /etc/nginx/landing.html.tpl
|
||||||
RUN chmod +x /run.sh \
|
RUN chmod +x /run.sh \
|
||||||
&& mkdir -p /run/nginx
|
&& mkdir -p /run/nginx
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: OpenClaw Assistant
|
name: OpenClaw Assistant
|
||||||
version: "0.5.4"
|
version: "0.5.6"
|
||||||
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
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>OpenClaw Assistant</title>
|
||||||
|
<style>
|
||||||
|
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;margin:0;padding:16px;background:#0b0f14;color:#e6edf3}
|
||||||
|
a,button{font:inherit}
|
||||||
|
.card{max-width:1100px;margin:0 auto;background:#111827;border:1px solid #1f2937;border-radius:12px;padding:16px}
|
||||||
|
.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
|
||||||
|
.btn{background:#2563eb;color:white;border:0;border-radius:10px;padding:10px 14px;cursor:pointer;text-decoration:none;display:inline-block}
|
||||||
|
.btn.secondary{background:#334155}
|
||||||
|
.muted{color:#9ca3af;font-size:14px}
|
||||||
|
.term{margin-top:14px;height:70vh;min-height:420px;border:1px solid #1f2937;border-radius:10px;overflow:hidden}
|
||||||
|
iframe{width:100%;height:100%;border:0;background:black}
|
||||||
|
code{background:#0b1220;padding:2px 6px;border-radius:6px}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card">
|
||||||
|
<h2 style="margin:0 0 8px 0">OpenClaw Assistant</h2>
|
||||||
|
|
||||||
|
<div class="row" style="margin-bottom:6px">
|
||||||
|
<a class="btn" id="gwbtn" href="__GATEWAY_PUBLIC_URL____GW_PUBLIC_URL_PATH__?token=__GATEWAY_TOKEN__" target="_blank" rel="noopener noreferrer">Open Gateway Web UI</a>
|
||||||
|
<a class="btn secondary" href="./terminal/" target="_self">Open Terminal (full page)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="muted" id="gwhint">
|
||||||
|
Tip: The gateway UI is intentionally opened outside of Ingress to avoid websocket/proxy issues.
|
||||||
|
Configure <code>gateway_public_url</code> in the add-on options, then complete onboarding in the terminal.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var publicUrl = "__GATEWAY_PUBLIC_URL__";
|
||||||
|
var token = "__GATEWAY_TOKEN__";
|
||||||
|
var btn = document.getElementById("gwbtn");
|
||||||
|
var hint = document.getElementById("gwhint");
|
||||||
|
|
||||||
|
if (!publicUrl || publicUrl === "__GATEWAY_PUBLIC_URL__") {
|
||||||
|
btn.style.display = "none";
|
||||||
|
hint.innerHTML = "Configure <code>gateway_public_url</code> in the add-on options to enable the external Gateway UI link.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!token || token === "__GATEWAY_TOKEN__") {
|
||||||
|
btn.style.display = "none";
|
||||||
|
hint.innerHTML = "Gateway token not found yet. Open the terminal below and run <code>openclaw onboard</code> (or <code>openclaw configure</code>) to finish setup.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="term">
|
||||||
|
<iframe src="./terminal/" title="Terminal"></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -44,64 +44,11 @@ http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Landing page (shown inside HA Ingress)
|
# Landing page (shown inside HA Ingress)
|
||||||
# - Shows the web terminal (if enabled)
|
# Served as a real HTML file to avoid fragile quoting inside nginx.conf.
|
||||||
# - Provides a button to open the Gateway Web UI in a separate tab (not embedded)
|
|
||||||
location = / {
|
location = / {
|
||||||
|
root /etc/nginx/html;
|
||||||
default_type text/html;
|
default_type text/html;
|
||||||
|
try_files /index.html =404;
|
||||||
# NOTE: __GATEWAY_PUBLIC_URL__ is configured via add-on option gateway_public_url.
|
|
||||||
# We keep it flexible because the right URL depends on how the user exposes HA/gateway
|
|
||||||
# (Nabu Casa, DuckDNS, LAN, etc.).
|
|
||||||
|
|
||||||
return 200 '<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>OpenClaw Assistant</title>
|
|
||||||
<style>
|
|
||||||
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;margin:0;padding:16px;background:#0b0f14;color:#e6edf3}
|
|
||||||
a,button{font:inherit}
|
|
||||||
.card{max-width:1100px;margin:0 auto;background:#111827;border:1px solid #1f2937;border-radius:12px;padding:16px}
|
|
||||||
.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
|
|
||||||
.btn{background:#2563eb;color:white;border:0;border-radius:10px;padding:10px 14px;cursor:pointer;text-decoration:none;display:inline-block}
|
|
||||||
.btn.secondary{background:#334155}
|
|
||||||
.muted{color:#9ca3af;font-size:14px}
|
|
||||||
.term{margin-top:14px;height:70vh;min-height:420px;border:1px solid #1f2937;border-radius:10px;overflow:hidden}
|
|
||||||
iframe{width:100%;height:100%;border:0;background:black}
|
|
||||||
code{background:#0b1220;padding:2px 6px;border-radius:6px}
|
|
||||||
</style>
|
|
||||||
</head><body>
|
|
||||||
<div class="card">
|
|
||||||
<h2 style="margin:0 0 8px 0">OpenClaw Assistant</h2>
|
|
||||||
<div class="row" style="margin-bottom:6px">
|
|
||||||
<a class="btn" id="gwbtn" href="__GATEWAY_PUBLIC_URL____GW_PUBLIC_URL_PATH__?token=__GATEWAY_TOKEN__" target="_blank" rel="noopener noreferrer">Open Gateway Web UI</a>
|
|
||||||
<a class="btn secondary" href="./terminal/" target="_self">Open Terminal (full page)</a>
|
|
||||||
</div>
|
|
||||||
<div class="muted" id="gwhint">
|
|
||||||
Tip: The gateway UI is intentionally opened outside of Ingress to avoid websocket/proxy issues.
|
|
||||||
Configure <code>gateway_public_url</code> in the add-on options, then complete onboarding in the terminal.
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
(function(){
|
|
||||||
var publicUrl = '__GATEWAY_PUBLIC_URL__';
|
|
||||||
var token = '__GATEWAY_TOKEN__';
|
|
||||||
var btn = document.getElementById('gwbtn');
|
|
||||||
var hint = document.getElementById('gwhint');
|
|
||||||
if (!publicUrl || publicUrl === '__GATEWAY_PUBLIC_URL__') {
|
|
||||||
btn.style.display = 'none';
|
|
||||||
hint.innerHTML = 'Configure <code>gateway_public_url</code> in the add-on options to enable the external Gateway UI link.';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!token || token === '__GATEWAY_TOKEN__') {
|
|
||||||
// Token not known yet (likely before onboarding). Don't show a broken link.
|
|
||||||
btn.style.display = 'none';
|
|
||||||
hint.innerHTML = 'Gateway token not found yet. Open the terminal below and run <code>openclaw onboard</code> (or <code>openclaw configure</code>) to finish setup.';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<div class="term">
|
|
||||||
<iframe src="./terminal/" title="Terminal"></iframe>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body></html>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# (Optional) Gateway UI via ingress has been intentionally removed.
|
# (Optional) Gateway UI via ingress has been intentionally removed.
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
tpl = Path('/etc/nginx/nginx.conf.tpl').read_text()
|
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','')
|
public_url = os.environ.get('GW_PUBLIC_URL','')
|
||||||
|
|
||||||
# Best-effort: read token from OpenClaw config if it exists and is strict JSON.
|
# Best-effort: read token from OpenClaw config if it exists and is strict JSON.
|
||||||
@@ -193,11 +194,17 @@ try:
|
|||||||
except Exception:
|
except Exception:
|
||||||
token = ''
|
token = ''
|
||||||
|
|
||||||
conf = tpl.replace('__GATEWAY_TOKEN__', token)
|
gw_path = '' if public_url.endswith('/') else '/'
|
||||||
conf = conf.replace('__GATEWAY_PUBLIC_URL__', public_url)
|
|
||||||
conf = conf.replace('__GW_PUBLIC_URL_PATH__', '' if public_url.endswith('/') else '/')
|
|
||||||
|
|
||||||
|
conf = tpl
|
||||||
Path('/etc/nginx/nginx.conf').write_text(conf)
|
Path('/etc/nginx/nginx.conf').write_text(conf)
|
||||||
|
|
||||||
|
landing = landing_tpl.replace('__GATEWAY_TOKEN__', token)
|
||||||
|
landing = landing.replace('__GATEWAY_PUBLIC_URL__', public_url)
|
||||||
|
landing = landing.replace('__GW_PUBLIC_URL_PATH__', gw_path)
|
||||||
|
|
||||||
|
Path('/etc/nginx/html').mkdir(parents=True, exist_ok=True)
|
||||||
|
Path('/etc/nginx/html/index.html').write_text(landing)
|
||||||
PY
|
PY
|
||||||
|
|
||||||
echo "Starting ingress proxy (nginx) on :8099 ..."
|
echo "Starting ingress proxy (nginx) on :8099 ..."
|
||||||
|
|||||||
Reference in New Issue
Block a user