fitz0401 commited on
Commit
b0a7175
·
verified ·
1 Parent(s): a2ef01f

Create start-openclaw.sh

Browse files
Files changed (1) hide show
  1. start-openclaw.sh +57 -0
start-openclaw.sh ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # 1. 补全目录
6
+ mkdir -p /root/.openclaw/agents/main/sessions
7
+ mkdir -p /root/.openclaw/credentials
8
+ mkdir -p /root/.openclaw/sessions
9
+
10
+ # 2. 执行恢复
11
+ python3 /app/sync.py restore
12
+
13
+ # 3. 处理 API 地址
14
+ CLEAN_BASE=$(echo "$OPENAI_API_BASE" | sed "s|/chat/completions||g" | sed "s|/v1/|/v1|g" | sed "s|/v1$|/v1|g")
15
+
16
+ # 4. 生成配置文件
17
+ cat > /root/.openclaw/openclaw.json <<EOF
18
+ {
19
+ "models": {
20
+ "providers": {
21
+ "nvidia": {
22
+ "baseUrl": "$CLEAN_BASE",
23
+ "apiKey": "$OPENAI_API_KEY",
24
+ "api": "openai-completions",
25
+ "models": [
26
+ { "id": "$MODEL", "name": "$MODEL", "contextWindow": 128000 }
27
+ ]
28
+ }
29
+ }
30
+ },
31
+ "agents": { "defaults": { "model": { "primary": "nvidia/$MODEL" } } },
32
+ "commands": {
33
+ "restart": true
34
+ },
35
+ "gateway": {
36
+ "mode": "local",
37
+ "bind": "lan",
38
+ "port": $PORT,
39
+ "trustedProxies": ["0.0.0.0/0"],
40
+ "auth": { "mode": "token", "token": "$OPENCLAW_GATEWAY_PASSWORD" },
41
+ "controlUi": {
42
+ "enabled": true,
43
+ "allowInsecureAuth": true,
44
+ "dangerouslyDisableDeviceAuth": true,
45
+ "dangerouslyAllowHostHeaderOriginFallback": true
46
+ },
47
+ }
48
+ }
49
+ EOF
50
+
51
+ # 5. 启动定时备份 (每 1 小时)
52
+ (while true; do sleep 3600; python3 /app/sync.py backup; done) &
53
+
54
+ # 6. 运行
55
+ openclaw doctor --fix
56
+
57
+ exec openclaw gateway run --port $PORT