R1000 commited on
Commit
0635916
·
verified ·
1 Parent(s): 6faa78f

Create start_openclaw.sh

Browse files
Files changed (1) hide show
  1. start_openclaw.sh +82 -0
start_openclaw.sh ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_manager.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. สร้างไฟล์กำหนดค่า OpenClaw
17
+ cat > /root/.openclaw/openclaw.json <<EOF
18
+ {
19
+ "logging": {
20
+ "level": "debug",
21
+ "consoleLevel": "debug",
22
+ "consoleStyle": "pretty",
23
+ "redactSensitive": "tools"
24
+ },
25
+ "session": {
26
+ "dmScope": "per-channel-peer"
27
+ },
28
+ "models": {
29
+ "providers": {
30
+ "nvidia": {
31
+ "baseUrl": "$OPENAI_API_BASE",
32
+ "apiKey": "$OPENAI_API_KEY",
33
+ "api": "openai-completions",
34
+ "models": [
35
+ { "id": "$MODEL", "name": "$MODEL", "contextWindow": 128000 }
36
+ ]
37
+ }
38
+ }
39
+ },
40
+ "agents": { "defaults": { "model": { "primary": "nvidia/$MODEL" } } },
41
+ "commands": {
42
+ "restart": true
43
+ },
44
+ "gateway": {
45
+ "mode": "local",
46
+ "bind": "lan",
47
+ "port": $PORT,
48
+ "trustedProxies": ["0.0.0.0/0"],
49
+ "auth": { "mode": "token", "token": "$OPENCLAW_GATEWAY_PASSWORD" },
50
+ "controlUi": {
51
+ "allowedOrigins": ["https://r1000-openclaw.hf.space"],
52
+ "enabled": true,
53
+ "allowInsecureAuth": true,
54
+ "dangerouslyDisableDeviceAuth": true,
55
+ "dangerouslyAllowHostHeaderOriginFallback": true
56
+ },
57
+ },
58
+ "tools": {
59
+ "agentToAgent": {
60
+ "enabled": true,
61
+ "allow": ["assistant", "coder", "designer"]
62
+ },
63
+ "allow": ["exec", "read", "write", "edit", "process", "bash", "sessions_spawn", "sessions_send", "sessions_list", "message", "gateway", "cron"],
64
+ "deny": [],
65
+ "elevated": {
66
+ "enabled": true,
67
+ "allowFrom": {
68
+ "line": ["*"],
69
+ "discord": ["*"]
70
+ }
71
+ }
72
+ }
73
+ }
74
+ EOF
75
+
76
+ # 5. เริ่มต้นการสำรองข้อมูลอัตโนมัติทุก 30 นาที
77
+ (while true; do sleep 1800; python3 /app/sync.py backup; done) &
78
+
79
+ # 6. ตรวจสอบและแก้ไขปัญหาการกำหนดค่า จากนั้นรันเกตเวย์
80
+ openclaw doctor --fix
81
+
82
+ exec openclaw gateway run --port $PORT