M-openclaw / start-openclaw.sh
AZILS's picture
Update start-openclaw.sh
3d1b131 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. 生成配置文件
cat > /root/.openclaw/openclaw.json <<EOF
{
"models": {
"providers": {
"siliconflow": {
"baseUrl": "$CLEAN_BASE",
"apiKey": "$OPENAI_API_KEY",
"api": "openai-completions",
"models": [
{ "id": "$MODEL", "name": "$MODEL", "contextWindow": 128000 }
]
}
}
},
"agents": { "defaults": { "model": { "primary": "siliconflow/$MODEL" } } },
"commands": {
"restart": true
},
"gateway": {
"mode": "local", "bind": "lan", "port": $PORT,
"trustedProxies": ["0.0.0.0/0","10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"],
"auth": { "mode": "token", "token": "$OPENCLAW_GATEWAY_PASSWORD" },
"controlUi": {
"allowedOrigins": ["https://azils-m-openclaw.hf.space","https://huggingface.co/spaces/AZILS/M-openclaw","http://10.108.58.130:7860"],
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
}
}
}
EOF
# 5. 启动定时备份 (每 1 小时)
(while true; do sleep 3600; python3 /app/sync.py backup; done) &
# 6. 运行
openclaw doctor --fix
exec openclaw gateway run --port $PORT