Spaces:
Running
Running
Somrat Sorkar commited on
Commit Β·
aeb1d95
1
Parent(s): 567a914
Auto-inject gateway token into Control UI to bypass pairing
Browse files
start.sh
CHANGED
|
@@ -193,7 +193,7 @@ printf " β %-40s β\n" "Backup: β not configured"
|
|
| 193 |
fi
|
| 194 |
if [ -n "$SPACE_HOST" ]; then
|
| 195 |
printf " β %-40s β\n" "Keep-alive: β
every ${KEEP_ALIVE_INTERVAL:-300}s"
|
| 196 |
-
printf " β %-40s β\n" "Control UI: https://${SPACE_HOST}"
|
| 197 |
else
|
| 198 |
printf " β %-40s β\n" "Keep-alive: βΈοΈ local mode"
|
| 199 |
fi
|
|
@@ -242,24 +242,38 @@ echo ""
|
|
| 242 |
# Set model via environment for the gateway
|
| 243 |
export LLM_MODEL="$LLM_MODEL"
|
| 244 |
|
| 245 |
-
# For headless Docker:
|
| 246 |
-
#
|
| 247 |
-
mkdir -p /home/node/.openclaw/
|
| 248 |
-
cat > /home/node/.openclaw/
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
}
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
openclaw gateway run --port 7860 --bind lan --verbose 2>&1 | tee -a /home/node/.openclaw/gateway.log &
|
| 265 |
GATEWAY_PID=$!
|
|
|
|
| 193 |
fi
|
| 194 |
if [ -n "$SPACE_HOST" ]; then
|
| 195 |
printf " β %-40s β\n" "Keep-alive: β
every ${KEEP_ALIVE_INTERVAL:-300}s"
|
| 196 |
+
printf " β %-40s β\n" "Control UI: https://${SPACE_HOST}/__openclaw__/canvas/auto-login.html"
|
| 197 |
else
|
| 198 |
printf " β %-40s β\n" "Keep-alive: βΈοΈ local mode"
|
| 199 |
fi
|
|
|
|
| 242 |
# Set model via environment for the gateway
|
| 243 |
export LLM_MODEL="$LLM_MODEL"
|
| 244 |
|
| 245 |
+
# For headless Docker: auto-approve the Control UI by injecting token into localStorage
|
| 246 |
+
# Create a wrapper page that auto-configures the token and loads the dashboard
|
| 247 |
+
mkdir -p /home/node/.openclaw/canvas
|
| 248 |
+
cat > /home/node/.openclaw/canvas/auto-login.html <<'HTMLEOF'
|
| 249 |
+
<!DOCTYPE html>
|
| 250 |
+
<html>
|
| 251 |
+
<head>
|
| 252 |
+
<meta charset="utf-8">
|
| 253 |
+
<title>HuggingClaw β Connecting...</title>
|
| 254 |
+
<script>
|
| 255 |
+
// Auto-inject gateway token into Control UI on startup
|
| 256 |
+
const token = 'GATEWAY_TOKEN_PLACEHOLDER';
|
| 257 |
+
if (token && token !== 'GATEWAY_TOKEN_PLACEHOLDER') {
|
| 258 |
+
localStorage.setItem('openclaw:gateway:token', token);
|
| 259 |
+
localStorage.setItem('openclaw:gateway:url', window.location.origin);
|
| 260 |
+
console.log('β
Gateway token auto-configured. Redirecting to dashboard...');
|
| 261 |
+
// Redirect to the actual Control UI after a tiny delay
|
| 262 |
+
setTimeout(() => window.location.href = '/', 100);
|
| 263 |
+
} else {
|
| 264 |
+
document.body.innerHTML = '<h1>β οΈ Gateway token not configured</h1>';
|
| 265 |
}
|
| 266 |
+
</script>
|
| 267 |
+
</head>
|
| 268 |
+
<body>
|
| 269 |
+
<h1>Connecting to OpenClaw...</h1>
|
| 270 |
+
<p>If this page doesn't redirect, your gateway token may not be set.</p>
|
| 271 |
+
</body>
|
| 272 |
+
</html>
|
| 273 |
+
HTMLEOF
|
| 274 |
+
|
| 275 |
+
# Replace the placeholder with the actual token
|
| 276 |
+
sed -i "s|GATEWAY_TOKEN_PLACEHOLDER|$GATEWAY_TOKEN|g" /home/node/.openclaw/canvas/auto-login.html
|
| 277 |
|
| 278 |
openclaw gateway run --port 7860 --bind lan --verbose 2>&1 | tee -a /home/node/.openclaw/gateway.log &
|
| 279 |
GATEWAY_PID=$!
|