@@ -13,15 +13,18 @@ mkdir -p "$OPENCLAW_DIR/canvas" "$OPENCLAW_DIR/cron" "$OPENCLAW_DIR/workspace" "
1313CONFIG_FILE=" $OPENCLAW_DIR /openclaw.json"
1414if [ ! -f " $CONFIG_FILE " ]; then
1515 echo " Creating default OpenClaw config..."
16- cat > " $CONFIG_FILE " << ' EOF '
16+ cat > " $CONFIG_FILE " << EOF
1717{
1818 "gateway": {
19- "bind": "lan",
2019 "port": 18789,
20+ "bind": "lan",
2121 "controlUi": {
2222 "dangerouslyAllowHostHeaderOriginFallback": true,
2323 "allowInsecureAuth": true,
2424 "dangerouslyDisableDeviceAuth": true
25+ },
26+ "auth": {
27+ "token": "${OPENCLAW_GATEWAY_TOKEN:- openclaw} "
2528 }
2629 }
2730}
3134const fs = require('fs');
3235const JSON5 = require('json5');
3336const configPath = '$CONFIG_FILE ';
37+ const envToken = process.env.OPENCLAW_GATEWAY_TOKEN || 'openclaw';
3438try {
3539 const config = JSON5.parse(fs.readFileSync(configPath, 'utf8'));
36- const cui = ((config.gateway = config.gateway || {}).controlUi = config.gateway.controlUi || {});
37- const gw = config.gateway;
40+ const gw = (config.gateway = config.gateway || {});
41+ const cui = (gw.controlUi = gw.controlUi || {});
42+ const auth = (gw.auth = gw.auth || {});
3843 let changed = false;
39- if (!('bind' in gw)) { gw.bind = 'lan' ; changed = true; }
40- if (!('port' in gw)) { gw.port = 18789 ; changed = true; }
44+ if (gw.port !== 18789) { gw.port = 18789 ; changed = true; }
45+ if (gw.bind !== 'lan') { gw.bind = 'lan' ; changed = true; }
4146 if (!('dangerouslyAllowHostHeaderOriginFallback' in cui) && !('allowedOrigins' in cui)) {
4247 cui.dangerouslyAllowHostHeaderOriginFallback = true;
4348 changed = true;
4449 }
45- if (!('allowInsecureAuth' in cui)) {
46- cui.allowInsecureAuth = true;
47- changed = true;
48- }
49- if (!('dangerouslyDisableDeviceAuth' in cui)) {
50- cui.dangerouslyDisableDeviceAuth = true;
51- changed = true;
52- }
50+ if (!('allowInsecureAuth' in cui)) { cui.allowInsecureAuth = true; changed = true; }
51+ if (!('dangerouslyDisableDeviceAuth' in cui)) { cui.dangerouslyDisableDeviceAuth = true; changed = true; }
52+ if (auth.token !== envToken) { auth.token = envToken; changed = true; }
5353 if (changed) {
5454 fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
5555 console.log('Updated OpenClaw config for DAppNode HTTP deployment');
0 commit comments