Spaces:
Runtime error
Runtime error
tao-shen commited on
Commit Β·
cb0513d
1
Parent(s): 331869d
fix: use fixed auth token + python-based token injection + restore entrypoint inject
Browse files- openclaw.json +1 -1
- scripts/entrypoint.sh +7 -0
- scripts/inject-token.sh +25 -10
- scripts/sync_hf.py +1 -1
openclaw.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"mode": "local",
|
| 4 |
"bind": "lan",
|
| 5 |
"port": 7860,
|
| 6 |
-
"auth": { "
|
| 7 |
"trustedProxies": [
|
| 8 |
"0.0.0.0/0"
|
| 9 |
],
|
|
|
|
| 3 |
"mode": "local",
|
| 4 |
"bind": "lan",
|
| 5 |
"port": 7860,
|
| 6 |
+
"auth": { "token": "hf-space-public-token" },
|
| 7 |
"trustedProxies": [
|
| 8 |
"0.0.0.0/0"
|
| 9 |
],
|
scripts/entrypoint.sh
CHANGED
|
@@ -48,6 +48,13 @@ touch /home/node/logs/app.log
|
|
| 48 |
ENTRYPOINT_END=$(date +%s)
|
| 49 |
echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
# ββ Start OpenClaw via sync_hf.py (don't wait for DNS β it runs in bg) βββββ
|
| 52 |
echo "[entrypoint] Starting OpenClaw via sync_hf.py..."
|
| 53 |
echo "[entrypoint] DNS resolution running in background (PID $DNS_PID), app will use it when ready"
|
|
|
|
| 48 |
ENTRYPOINT_END=$(date +%s)
|
| 49 |
echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"
|
| 50 |
|
| 51 |
+
# ββ Inject auth token into Control UI HTML βββββββββββββββββββββββββββββββββ
|
| 52 |
+
INJECT_START=$(date +%s)
|
| 53 |
+
if [ -x /home/node/scripts/inject-token.sh ]; then
|
| 54 |
+
bash /home/node/scripts/inject-token.sh
|
| 55 |
+
fi
|
| 56 |
+
echo "[TIMER] Token inject: $(($(date +%s) - INJECT_START))s"
|
| 57 |
+
|
| 58 |
# ββ Start OpenClaw via sync_hf.py (don't wait for DNS β it runs in bg) βββββ
|
| 59 |
echo "[entrypoint] Starting OpenClaw via sync_hf.py..."
|
| 60 |
echo "[entrypoint] DNS resolution running in background (PID $DNS_PID), app will use it when ready"
|
scripts/inject-token.sh
CHANGED
|
@@ -1,15 +1,30 @@
|
|
| 1 |
#!/bin/sh
|
| 2 |
# Inject auto-token config into Control UI so the browser auto-connects
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
exit 0
|
| 12 |
-
fi
|
| 13 |
-
done
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/sh
|
| 2 |
# Inject auto-token config into Control UI so the browser auto-connects
|
| 3 |
+
# The token must match gateway.auth.token in openclaw.json
|
| 4 |
+
TOKEN="hf-space-public-token"
|
| 5 |
|
| 6 |
+
INDEX_HTML="/app/openclaw/dist/control-ui/index.html"
|
| 7 |
|
| 8 |
+
if [ ! -f "$INDEX_HTML" ]; then
|
| 9 |
+
echo "[inject-token] WARNING: $INDEX_HTML not found, skipping"
|
| 10 |
+
exit 0
|
| 11 |
+
fi
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Create the injection script
|
| 14 |
+
INJECT_SCRIPT="<script>!function(){var K='openclaw.control.settings.v1';try{var s=JSON.parse(localStorage.getItem(K)||'{}');if(!s.token||s.token===''){s.token='${TOKEN}';localStorage.setItem(K,JSON.stringify(s))}}catch(e){}}()</script>"
|
| 15 |
+
|
| 16 |
+
# Use python3 for reliable string replacement (avoids sed delimiter issues)
|
| 17 |
+
python3 -c "
|
| 18 |
+
import sys
|
| 19 |
+
f = '${INDEX_HTML}'
|
| 20 |
+
with open(f, 'r') as fh:
|
| 21 |
+
html = fh.read()
|
| 22 |
+
inject = '''${INJECT_SCRIPT}'''
|
| 23 |
+
if '</head>' in html and inject not in html:
|
| 24 |
+
html = html.replace('</head>', inject + '</head>')
|
| 25 |
+
with open(f, 'w') as fh:
|
| 26 |
+
fh.write(html)
|
| 27 |
+
print('[inject-token] Token injected into ' + f)
|
| 28 |
+
else:
|
| 29 |
+
print('[inject-token] Skipped (already injected or no </head> found)')
|
| 30 |
+
"
|
scripts/sync_hf.py
CHANGED
|
@@ -327,7 +327,7 @@ class OpenClawFullSync:
|
|
| 327 |
"mode": "local",
|
| 328 |
"bind": "lan",
|
| 329 |
"port": 7860,
|
| 330 |
-
"auth": {"
|
| 331 |
"trustedProxies": ["0.0.0.0/0"],
|
| 332 |
"controlUi": {
|
| 333 |
"allowInsecureAuth": True,
|
|
|
|
| 327 |
"mode": "local",
|
| 328 |
"bind": "lan",
|
| 329 |
"port": 7860,
|
| 330 |
+
"auth": {"token": "hf-space-public-token"},
|
| 331 |
"trustedProxies": ["0.0.0.0/0"],
|
| 332 |
"controlUi": {
|
| 333 |
"allowInsecureAuth": True,
|