File size: 1,038 Bytes
71a1cdb
 
 
 
 
941c9e1
 
6ca967b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941c9e1
 
 
 
 
 
 
 
 
 
 
 
 
 
71a1cdb
6ca967b
 
71a1cdb
 
6bec2bb
941c9e1
 
6ca967b
941c9e1
 
 
 
 
 
 
 
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
#!/bin/bash

mkdir -p /run/dbus
dbus-daemon --system --fork 2>/dev/null || true

export PATH=$PATH:/usr/local/bin

# OpenClaw config
mkdir -p ~/.config/openclaw
cat > ~/.config/openclaw/config.json << 'EOF'
{
  "gateway": {
    "mode": "local",
    "port": 9000,
    "bind": "lan"
  }
}
EOF

echo "=== Starting OpenClaw Gateway (background) ==="
while true; do
    openclaw gateway --port 9000 --bind lan --allow-unconfigured
    sleep 10
done &

sleep 5

echo "=== Starting ttyd terminal ==="
ttyd \
    --port 8080 \
    --interface 127.0.0.1 \
    --writable \
    bash &
TTYD_PID=$!

sleep 3

echo "=== Starting nginx ==="
nginx -g "daemon off;" &
NGINX_PID=$!

echo "
✅ Terminal: your-space.hf.space/
🤖 OpenClaw: port 9000 (background)
"

# Keep alive
while true; do
    if ! kill -0 $TTYD_PID 2>/dev/null; then
        ttyd --port 8080 --interface 127.0.0.1 --writable bash &
        TTYD_PID=$!
    fi
    if ! kill -0 $NGINX_PID 2>/dev/null; then
        nginx -g "daemon off;" &
        NGINX_PID=$!
    fi
    sleep 10
done