R1000 commited on
Commit
41f946d
·
verified ·
1 Parent(s): 0635916

Update start_openclaw.sh

Browse files
Files changed (1) hide show
  1. start_openclaw.sh +21 -26
start_openclaw.sh CHANGED
@@ -1,19 +1,21 @@
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": {
@@ -22,13 +24,11 @@ cat > /root/.openclaw/openclaw.json <<EOF
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": [
@@ -38,9 +38,7 @@ cat > /root/.openclaw/openclaw.json <<EOF
38
  }
39
  },
40
  "agents": { "defaults": { "model": { "primary": "nvidia/$MODEL" } } },
41
- "commands": {
42
- "restart": true
43
- },
44
  "gateway": {
45
  "mode": "local",
46
  "bind": "lan",
@@ -53,7 +51,7 @@ cat > /root/.openclaw/openclaw.json <<EOF
53
  "allowInsecureAuth": true,
54
  "dangerouslyDisableDeviceAuth": true,
55
  "dangerouslyAllowHostHeaderOriginFallback": true
56
- },
57
  },
58
  "tools": {
59
  "agentToAgent": {
@@ -61,22 +59,19 @@ cat > /root/.openclaw/openclaw.json <<EOF
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
 
 
1
  #!/bin/bash
2
 
3
+ # ปิด Script ทันทีหากเกิด Error และห้ามใช้ตัวแปรที่ไม่ได้ประกาศ
4
+ set -euo pipefail
5
 
6
+ # 1. สร้างไดเรกทอรีที่จำเป็น (ใช้บรรทัดเดียวรวมกัน)
7
+ mkdir -p /root/.openclaw/{agents/main/sessions,credentials,sessions}
 
 
8
 
9
+ # 2. เรียกคืนข้อมูล (Restore) ริ่งา
10
  python3 /app/sync_manager.py restore
11
 
12
+ # 3. จัดการ API Base URL ให้สะาด (ล /v1 หรือ /chat/completions ที่ินมา)
13
+ # ใช้ Parameter Expansion ของ bash แทน sed เพื่อความเร็ว
14
+ CLEAN_BASE="${OPENAI_API_BASE%/chat/completions}"
15
+ CLEAN_BASE="${CLEAN_BASE%/}"
16
+ CLEAN_BASE="${CLEAN_BASE%/v1}"
17
 
18
+ # 4. สร้างไฟล์ openclaw.json (ตัดคอมมเกิน และจัดรูปแบบให้เป๊ะ)
19
  cat > /root/.openclaw/openclaw.json <<EOF
20
  {
21
  "logging": {
 
24
  "consoleStyle": "pretty",
25
  "redactSensitive": "tools"
26
  },
27
+ "session": { "dmScope": "per-channel-peer" },
 
 
28
  "models": {
29
  "providers": {
30
  "nvidia": {
31
+ "baseUrl": "${CLEAN_BASE}/v1",
32
  "apiKey": "$OPENAI_API_KEY",
33
  "api": "openai-completions",
34
  "models": [
 
38
  }
39
  },
40
  "agents": { "defaults": { "model": { "primary": "nvidia/$MODEL" } } },
41
+ "commands": { "restart": true },
 
 
42
  "gateway": {
43
  "mode": "local",
44
  "bind": "lan",
 
51
  "allowInsecureAuth": true,
52
  "dangerouslyDisableDeviceAuth": true,
53
  "dangerouslyAllowHostHeaderOriginFallback": true
54
+ }
55
  },
56
  "tools": {
57
  "agentToAgent": {
 
59
  "allow": ["assistant", "coder", "designer"]
60
  },
61
  "allow": ["exec", "read", "write", "edit", "process", "bash", "sessions_spawn", "sessions_send", "sessions_list", "message", "gateway", "cron"],
 
62
  "elevated": {
63
  "enabled": true,
64
+ "allowFrom": { "line": ["*"], "discord": ["*"] }
 
 
 
65
  }
66
  }
67
  }
68
  EOF
69
 
70
+ # 5. เริ่มระบบ Backup อัตโนมัติ (ใส่ & เพื่อรั background)
71
+ python3 /app/sync_manager.py backup &
72
 
73
+ # 6. ตรวจสอบระบบและรัน Gateway
74
  openclaw doctor --fix
75
 
76
+ echo "🚀 Starting OpenClaw Gateway on port $PORT..."
77
+ exec openclaw gateway run --port "$PORT"