@ssdavidai/zoclaw 1.1.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/bootstrap.sh +36 -44
package/package.json
CHANGED
package/scripts/bootstrap.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# openclaw-tailscale-bootstrap.sh
|
|
3
3
|
# Run AFTER: zotail is configured + `openclaw configure` has been run.
|
|
4
4
|
# Patches the default openclaw config so the gateway is reachable
|
|
5
|
-
# via Tailscale (both TUI and Control UI in browser).
|
|
5
|
+
# via Tailscale Serve (both TUI and Control UI in browser).
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
8
8
|
CONFIG="${HOME}/.openclaw/openclaw.json"
|
|
@@ -14,19 +14,31 @@ if [ ! -f "$CONFIG" ]; then
|
|
|
14
14
|
exit 1
|
|
15
15
|
fi
|
|
16
16
|
|
|
17
|
-
echo "Patching openclaw config for Tailscale
|
|
17
|
+
echo "Patching openclaw config for Tailscale Serve..."
|
|
18
18
|
|
|
19
|
-
# Patch gateway config
|
|
19
|
+
# Patch gateway config — use OpenClaw's native tailscale integration
|
|
20
|
+
# instead of manually configuring tailscale serve.
|
|
21
|
+
# Ref: https://docs.openclaw.ai/gateway/tailscale
|
|
20
22
|
node -e "
|
|
21
23
|
const fs = require('fs');
|
|
22
24
|
const cfg = JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));
|
|
23
25
|
const gw = cfg.gateway ??= {};
|
|
24
26
|
|
|
25
|
-
//
|
|
27
|
+
// Bind to loopback only (required for tailscale serve mode)
|
|
28
|
+
gw.bind = 'loopback';
|
|
29
|
+
|
|
30
|
+
// Enable OpenClaw's native Tailscale Serve integration.
|
|
31
|
+
// The gateway will configure tailscale serve on startup
|
|
32
|
+
// and proxy HTTPS traffic from the tailnet to the local port.
|
|
33
|
+
gw.tailscale = { mode: 'serve' };
|
|
34
|
+
|
|
35
|
+
// Trust Tailscale identity headers — valid Tailscale Serve
|
|
36
|
+
// requests authenticate via x-forwarded-for + tailscale whois
|
|
37
|
+
// without needing a token or password.
|
|
26
38
|
gw.auth ??= {};
|
|
27
39
|
gw.auth.allowTailscale = true;
|
|
28
40
|
|
|
29
|
-
// Enable
|
|
41
|
+
// Enable the browser Control UI
|
|
30
42
|
gw.controlUi ??= {};
|
|
31
43
|
gw.controlUi.enabled = true;
|
|
32
44
|
|
|
@@ -34,11 +46,6 @@ node -e "
|
|
|
34
46
|
// names that don't match real command IDs, triggering audit warnings)
|
|
35
47
|
if (gw.nodes?.denyCommands) delete gw.nodes.denyCommands;
|
|
36
48
|
|
|
37
|
-
// Trust localhost as a reverse proxy (Tailscale serve proxies
|
|
38
|
-
// HTTPS -> HTTP on loopback and forwards X-Forwarded-For).
|
|
39
|
-
// This lets the gateway recognize .ts.net Host headers as local.
|
|
40
|
-
gw.trustedProxies = ['127.0.0.1/32'];
|
|
41
|
-
|
|
42
49
|
// Fix credentials dir permissions (create if missing)
|
|
43
50
|
const credDir = process.env.HOME + '/.openclaw/credentials';
|
|
44
51
|
if (!fs.existsSync(credDir)) fs.mkdirSync(credDir, { recursive: true, mode: 0o700 });
|
|
@@ -47,10 +54,11 @@ node -e "
|
|
|
47
54
|
fs.writeFileSync(process.argv[1], JSON.stringify(cfg, null, 2) + '\n');
|
|
48
55
|
" "$CONFIG"
|
|
49
56
|
|
|
57
|
+
echo " gateway.bind = loopback"
|
|
58
|
+
echo " gateway.tailscale.mode = serve"
|
|
50
59
|
echo " gateway.auth.allowTailscale = true"
|
|
51
60
|
echo " gateway.controlUi.enabled = true"
|
|
52
|
-
echo "
|
|
53
|
-
echo " nodes.denyCommands -> removed (invalid defaults)"
|
|
61
|
+
echo " nodes.denyCommands -> removed"
|
|
54
62
|
echo " credentials dir -> 700"
|
|
55
63
|
|
|
56
64
|
# Upgrade any existing paired devices to full admin scopes
|
|
@@ -73,43 +81,23 @@ fi
|
|
|
73
81
|
# Clear stale pairing requests
|
|
74
82
|
[ -f "$PENDING" ] && echo '{}' > "$PENDING"
|
|
75
83
|
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
# --force
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
pkill -f openclaw-gateway 2>/dev/null || true
|
|
86
|
-
sleep 2
|
|
87
|
-
openclaw gateway run > /dev/null 2>&1 &
|
|
88
|
-
sleep 5
|
|
89
|
-
echo " ✓ Gateway restarted"
|
|
90
|
-
else
|
|
91
|
-
# No gateway running — start fresh
|
|
92
|
-
openclaw gateway run > /dev/null 2>&1 &
|
|
93
|
-
sleep 5
|
|
94
|
-
echo " ✓ Gateway started"
|
|
95
|
-
fi
|
|
84
|
+
# Restart gateway to pick up config changes.
|
|
85
|
+
# The gateway will auto-configure tailscale serve on startup.
|
|
86
|
+
# Do NOT use --force as it regenerates the gateway identity
|
|
87
|
+
# and invalidates all existing device pairings.
|
|
88
|
+
echo "Restarting gateway..."
|
|
89
|
+
pkill -f openclaw-gateway 2>/dev/null || true
|
|
90
|
+
sleep 2
|
|
91
|
+
openclaw gateway run > /dev/null 2>&1 &
|
|
92
|
+
sleep 5
|
|
96
93
|
|
|
97
94
|
if ! pgrep -f openclaw-gateway > /dev/null 2>&1; then
|
|
98
95
|
echo "Warning: gateway is not running. Try 'openclaw gateway run' manually."
|
|
99
96
|
exit 1
|
|
100
97
|
fi
|
|
101
98
|
|
|
102
|
-
# Read
|
|
103
|
-
GW_PORT=$(node -pe "JSON.parse(require('fs').readFileSync('${CONFIG}','utf8')).gateway?.port ?? 18789")
|
|
99
|
+
# Read token and resolve MagicDNS hostname
|
|
104
100
|
TOKEN=$(node -pe "JSON.parse(require('fs').readFileSync('${CONFIG}','utf8')).gateway?.auth?.token ?? ''")
|
|
105
|
-
|
|
106
|
-
# Set up tailscale serve to expose the gateway Control UI on the tailnet
|
|
107
|
-
echo "Configuring Tailscale Serve..."
|
|
108
|
-
tailscale serve --bg --https=443 "http://127.0.0.1:${GW_PORT}" 2>/dev/null && \
|
|
109
|
-
echo " ✓ Tailscale Serve → localhost:${GW_PORT}" || \
|
|
110
|
-
echo " Warning: could not configure tailscale serve"
|
|
111
|
-
|
|
112
|
-
# Get the MagicDNS name for this machine
|
|
113
101
|
TS_HOSTNAME=$(tailscale status --json 2>/dev/null | node -pe "
|
|
114
102
|
const s = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
|
|
115
103
|
(s.Self.DNSName || '').replace(/\\.\$/, '')
|
|
@@ -118,8 +106,12 @@ TS_HOSTNAME=$(tailscale status --json 2>/dev/null | node -pe "
|
|
|
118
106
|
echo ""
|
|
119
107
|
echo "Ready!"
|
|
120
108
|
echo " TUI: openclaw tui"
|
|
121
|
-
if [ -n "$TS_HOSTNAME" ]
|
|
122
|
-
echo " Browser: https://${TS_HOSTNAME}
|
|
109
|
+
if [ -n "$TS_HOSTNAME" ]; then
|
|
110
|
+
echo " Browser: https://${TS_HOSTNAME}/"
|
|
111
|
+
if [ -n "$TOKEN" ]; then
|
|
112
|
+
echo " (with token: https://${TS_HOSTNAME}/#token=${TOKEN})"
|
|
113
|
+
fi
|
|
123
114
|
echo ""
|
|
124
115
|
echo " Accessible from any device on your tailnet."
|
|
116
|
+
echo " Tailscale identity auth is enabled — no token needed for tailnet users."
|
|
125
117
|
fi
|