he1237596 commited on
Commit
d6b7dbe
·
verified ·
1 Parent(s): dcf6fb1

Create start-openclaw.sh

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