openclaw / start_openclaw.sh
R1000's picture
Update start_openclaw.sh
b04a5ed verified
#!/bin/bash
set -e
# 1. สร้างไดเรกทอรีที่จำเป็น
mkdir -p /root/.openclaw/agents/main/sessions
mkdir -p /root/.openclaw/credentials
mkdir -p /root/.openclaw/sessions
# 2. ดำเนินการเรียกคืนข้อมูล (ถูกคอมเมนต์ไว้)
python3 /app/sync.py restore
# 3. จัดการที่อยู่ API ให้อยู่ในรูปแบบที่ถูกต้อง
CLEAN_BASE=$(echo "$OPENAI_API_BASE" | sed "s|/chat/completions||g" | sed "s|/v1/|/v1|g" | sed "s|/v1$|/v1|g")
# 4. สร้างไฟล์กำหนดค่า OpenClaw
cat > /root/.openclaw/openclaw.json <<EOF
{
"logging": {
"level": "debug",
"consoleLevel": "debug",
"consoleStyle": "pretty",
"redactSensitive": "tools"
},
"session": {
"dmScope": "per-channel-peer"
},
"models": {
"providers": {
"nvidia": {
"baseUrl": "$OPENAI_API_BASE",
"apiKey": "$OPENAI_API_KEY",
"api": "openai-completions",
"models": [
{ "id": "$MODEL", "name": "$MODEL", "contextWindow": 128000 }
]
}
}
},
"agents": { "defaults": { "model": { "primary": "nvidia/$MODEL" } } },
"commands": {
"restart": true
},
"gateway": {
"mode": "local",
"bind": "lan",
"port": $PORT,
"trustedProxies": ["0.0.0.0/0"],
"auth": { "mode": "token", "token": "$OPENCLAW_GATEWAY_PASSWORD" },
"controlUi": {
"allowedOrigins": ["https://r1000-openclaw.hf.space"],
"enabled": true,
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true,
"dangerouslyAllowHostHeaderOriginFallback": true
},
},
"tools": {
"agentToAgent": {
"enabled": true,
"allow": ["assistant", "coder", "designer"]
},
"allow": ["exec", "read", "write", "edit", "process", "bash", "sessions_spawn", "sessions_send", "sessions_list", "message", "gateway", "cron"],
"deny": [],
"elevated": {
"enabled": true,
"allowFrom": {
"line": ["*"],
"discord": ["*"]
}
}
}
}
EOF
# 5. เริ่มต้นการสำรองข้อมูลอัตโนมัติทุก 30 นาที
(while true; do sleep 1800; python3 /app/sync.py backup; done) &
# 6. ตรวจสอบและแก้ไขปัญหาการกำหนดค่า จากนั้นรันเกตเวย์
openclaw doctor --fix
exec openclaw gateway run --port $PORT