-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
86 lines (80 loc) · 2.89 KB
/
entrypoint.sh
File metadata and controls
86 lines (80 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -e
# Ensure the openclaw data directory exists
OPENCLAW_DIR="${OPENCLAW_STATE_DIR:-/home/node/.openclaw}"
# Create required subdirectories and set ownership
mkdir -p "$OPENCLAW_DIR/canvas" "$OPENCLAW_DIR/cron" "$OPENCLAW_DIR/workspace" "$OPENCLAW_DIR/sessions"
# ---------------------------------------------------------------------------
# Ensure gateway config has controlUi origin setting (required for non-loopback)
# ---------------------------------------------------------------------------
CONFIG_FILE="$OPENCLAW_DIR/openclaw.json"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Creating default OpenClaw config..."
cat > "$CONFIG_FILE" << 'EOF'
{
"gateway": {
"bind": "lan",
"port": 18789,
"controlUi": {
"dangerouslyAllowHostHeaderOriginFallback": true,
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
}
}
}
EOF
else
node -e "
const fs = require('fs');
const JSON5 = require('json5');
const configPath = '$CONFIG_FILE';
try {
const config = JSON5.parse(fs.readFileSync(configPath, 'utf8'));
const cui = ((config.gateway = config.gateway || {}).controlUi = config.gateway.controlUi || {});
const gw = config.gateway;
let changed = false;
if (!('bind' in gw)) { gw.bind = 'lan'; changed = true; }
if (!('port' in gw)) { gw.port = 18789; changed = true; }
if (!('dangerouslyAllowHostHeaderOriginFallback' in cui) && !('allowedOrigins' in cui)) {
cui.dangerouslyAllowHostHeaderOriginFallback = true;
changed = true;
}
if (!('allowInsecureAuth' in cui)) {
cui.allowInsecureAuth = true;
changed = true;
}
if (!('dangerouslyDisableDeviceAuth' in cui)) {
cui.dangerouslyDisableDeviceAuth = true;
changed = true;
}
if (changed) {
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
console.log('Updated OpenClaw config for DAppNode HTTP deployment');
}
} catch(e) { console.warn('Could not update openclaw.json:', e.message); }
" || true
fi
# ---------------------------------------------------------------------------
# Start setup wizard web UI in the background on port 8080
# ---------------------------------------------------------------------------
echo "Starting setup wizard on port 8080..."
node /app/setup-wizard/server.cjs &
WIZARD_PID=$!
echo "Setup wizard started (PID: ${WIZARD_PID})"
# ---------------------------------------------------------------------------
# Start ttyd (web terminal) in the background on port 7681
# ---------------------------------------------------------------------------
echo "Starting ttyd web terminal on port 7681..."
ttyd \
--port 7681 \
--interface 0.0.0.0 \
--writable \
/bin/bash -c "cd /home/node/.openclaw && exec /bin/bash -l" &
TTYD_PID=$!
echo "ttyd started (PID: ${TTYD_PID})"
# Execute the main command (runs as root; no-new-privileges prevents gosu/sudo)
if [ -n "$EXTRA_OPTS" ]; then
exec "$@" $EXTRA_OPTS
else
exec "$@"
fi