Update start-openclaw.sh
Browse files- start-openclaw.sh +21 -14
start-openclaw.sh
CHANGED
|
@@ -73,19 +73,16 @@ echo "🔄 微信 ClawBot 激活流程..."
|
|
| 73 |
|
| 74 |
ACCOUNTS_JSON="/root/.openclaw/openclaw-weixin/accounts/accounts.json"
|
| 75 |
|
| 76 |
-
# 检查 accounts.json 文件是否存在
|
| 77 |
if [[ -f "$ACCOUNTS_JSON" ]]; then
|
| 78 |
-
echo "✅ 检测到 accounts.json 文件 → 执行快速激活
|
| 79 |
|
| 80 |
openclaw config set plugins.entries.openclaw-weixin.enabled true || true
|
| 81 |
openclaw channels enable openclaw-weixin 2>/dev/null || true
|
| 82 |
else
|
| 83 |
echo "⚠️ 未检测到 accounts.json 文件 → 执行完整重新安装(需要扫码)..."
|
| 84 |
|
| 85 |
-
# 清理旧残留
|
| 86 |
rm -rf "/root/.openclaw/openclaw-weixin" 2>/dev/null || true
|
| 87 |
|
| 88 |
-
# 重新生成基础配置文件
|
| 89 |
cat > /root/.openclaw/openclaw.json <<EOF
|
| 90 |
{
|
| 91 |
"models": {
|
|
@@ -124,34 +121,44 @@ else
|
|
| 124 |
}
|
| 125 |
EOF
|
| 126 |
|
| 127 |
-
# 执行完整安装(会触发扫码)
|
| 128 |
npx -y @tencent-weixin/openclaw-weixin-cli@latest install
|
| 129 |
fi
|
| 130 |
|
| 131 |
echo "✅ 微信插件激活流程完成"
|
| 132 |
|
| 133 |
# ================================================
|
| 134 |
-
# 6. 执行 doctor --fix 修复配置
|
| 135 |
# ================================================
|
| 136 |
-
echo "🔧 执行 openclaw doctor --fix
|
| 137 |
openclaw doctor --fix || true
|
| 138 |
|
| 139 |
-
echo "✅ 配置修复完成"
|
| 140 |
-
|
| 141 |
# ================================================
|
| 142 |
-
# 7. 创建独立微信 Agent 并绑定(
|
| 143 |
# ================================================
|
| 144 |
-
echo "🔧 创建独立微信 Agent 并绑定
|
| 145 |
|
|
|
|
| 146 |
openclaw agents add wechat-agent --workspace /root/.openclaw/agents/wechat-agent --non-interactive || true
|
|
|
|
|
|
|
| 147 |
openclaw config set agents.registered.wechat-agent.model.primary "nvidia/$MODEL" || true
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
openclaw config set channels.openclaw-weixin.defaultAgent "wechat-agent" || true
|
| 150 |
|
| 151 |
echo "✅ 微信已绑定到独立 Agent (wechat-agent)"
|
| 152 |
|
| 153 |
# ================================================
|
| 154 |
-
# 8. 启
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
# ================================================
|
| 156 |
echo "⏰ 启动定时备份任务(每1小时)..."
|
| 157 |
(while true; do
|
|
@@ -160,7 +167,7 @@ echo "⏰ 启动定时备份任务(每1小时)..."
|
|
| 160 |
done) &
|
| 161 |
|
| 162 |
# ================================================
|
| 163 |
-
#
|
| 164 |
# ================================================
|
| 165 |
echo "🌟 启动 OpenClaw Gateway..."
|
| 166 |
exec openclaw gateway run --port $PORT
|
|
|
|
| 73 |
|
| 74 |
ACCOUNTS_JSON="/root/.openclaw/openclaw-weixin/accounts/accounts.json"
|
| 75 |
|
|
|
|
| 76 |
if [[ -f "$ACCOUNTS_JSON" ]]; then
|
| 77 |
+
echo "✅ 检测到 accounts.json 文件 → 执行快速激活"
|
| 78 |
|
| 79 |
openclaw config set plugins.entries.openclaw-weixin.enabled true || true
|
| 80 |
openclaw channels enable openclaw-weixin 2>/dev/null || true
|
| 81 |
else
|
| 82 |
echo "⚠️ 未检测到 accounts.json 文件 → 执行完整重新安装(需要扫码)..."
|
| 83 |
|
|
|
|
| 84 |
rm -rf "/root/.openclaw/openclaw-weixin" 2>/dev/null || true
|
| 85 |
|
|
|
|
| 86 |
cat > /root/.openclaw/openclaw.json <<EOF
|
| 87 |
{
|
| 88 |
"models": {
|
|
|
|
| 121 |
}
|
| 122 |
EOF
|
| 123 |
|
|
|
|
| 124 |
npx -y @tencent-weixin/openclaw-weixin-cli@latest install
|
| 125 |
fi
|
| 126 |
|
| 127 |
echo "✅ 微信插件激活流程完成"
|
| 128 |
|
| 129 |
# ================================================
|
| 130 |
+
# 6. 执行 doctor --fix 修复配置
|
| 131 |
# ================================================
|
| 132 |
+
echo "🔧 执行 openclaw doctor --fix ..."
|
| 133 |
openclaw doctor --fix || true
|
| 134 |
|
|
|
|
|
|
|
| 135 |
# ================================================
|
| 136 |
+
# 7. 创建独立微信 Agent 并强制绑定(关键隔离步骤)
|
| 137 |
# ================================================
|
| 138 |
+
echo "🔧 创建独立微信 Agent 并强制绑定(与主会话隔离)..."
|
| 139 |
|
| 140 |
+
# 创建独立 Agent
|
| 141 |
openclaw agents add wechat-agent --workspace /root/.openclaw/agents/wechat-agent --non-interactive || true
|
| 142 |
+
|
| 143 |
+
# 设置模型
|
| 144 |
openclaw config set agents.registered.wechat-agent.model.primary "nvidia/$MODEL" || true
|
| 145 |
+
|
| 146 |
+
# 强制绑定:把微信通道的所有消息路由到 wechat-agent
|
| 147 |
+
openclaw config set --json bindings '[{"agentId": "wechat-agent", "match": {"channel": "openclaw-weixin"}}]' || true
|
| 148 |
+
|
| 149 |
+
# 额外保险设置
|
| 150 |
openclaw config set channels.openclaw-weixin.defaultAgent "wechat-agent" || true
|
| 151 |
|
| 152 |
echo "✅ 微信已绑定到独立 Agent (wechat-agent)"
|
| 153 |
|
| 154 |
# ================================================
|
| 155 |
+
# 8. 重启 Gateway 让绑定生效
|
| 156 |
+
# ================================================
|
| 157 |
+
echo "🔄 重启 Gateway 使绑定生效..."
|
| 158 |
+
openclaw gateway restart || true
|
| 159 |
+
|
| 160 |
+
# ================================================
|
| 161 |
+
# 9. 启动定时备份
|
| 162 |
# ================================================
|
| 163 |
echo "⏰ 启动定时备份任务(每1小时)..."
|
| 164 |
(while true; do
|
|
|
|
| 167 |
done) &
|
| 168 |
|
| 169 |
# ================================================
|
| 170 |
+
# 10. 启动 OpenClaw Gateway
|
| 171 |
# ================================================
|
| 172 |
echo "🌟 启动 OpenClaw Gateway..."
|
| 173 |
exec openclaw gateway run --port $PORT
|