sharween commited on
Commit
1b3eca2
·
verified ·
1 Parent(s): d585626

Update start-openclaw.sh

Browse files
Files changed (1) hide show
  1. start-openclaw.sh +29 -8
start-openclaw.sh CHANGED
@@ -1,23 +1,31 @@
1
  #!/usr/bin/env bash
2
  set -e
3
 
 
4
  # 1️⃣ 目录准备
 
5
  mkdir -p /root/.openclaw/agents/main/sessions
6
  mkdir -p /root/.openclaw/credentials
7
  mkdir -p /root/.openclaw/sessions
8
  mkdir -p /root/.openclaw/config/plugins.entries
9
  mkdir -p /root/.openclaw/openclaw-weixin/accounts # 确保 accounts 目录存在
10
 
 
11
  # 2️⃣ 恢复历史备份(如果有)
12
- python3 /app/sync.py restore || true
 
13
 
14
- # 3️⃣ 处理 OpenAI API 地址
 
 
15
  CLEAN_BASE=$(echo "$OPENAI_API_BASE" \
16
  | sed "s|/chat/completions||g" \
17
  | sed "s|/v1/|/v1|g" \
18
  | sed "s|/v1$|/v1|g")
19
 
 
20
  # 4️⃣ 生成 OpenClaw 主配置文件
 
21
  cat > /root/.openclaw/openclaw.json <<EOF
22
  {
23
  "models": {
@@ -50,20 +58,33 @@ cat > /root/.openclaw/openclaw.json <<EOF
50
  }
51
  EOF
52
 
 
 
 
 
 
 
 
53
 
54
- # 5️⃣只在第一次启动时安装插件(后续不再执行)
 
 
55
  npx -y @tencent-weixin/openclaw-weixin-cli@latest install --no-restart || true
56
 
57
-
58
-
59
  # 7️⃣ 启动定时备份(每 1 小时一次)
 
60
  ( while true; do
61
  sleep 3600
62
  python3 /app/sync.py backup
63
  done ) &
64
 
65
- # 8️⃣ (建议)去掉 doctor --fix,防止 token 被删除
66
- # openclaw doctor --fix # 如需自检请手动执行
 
 
67
 
68
- # 9️⃣ 启动网关
 
 
69
  exec openclaw gateway run --port $PORT
 
1
  #!/usr/bin/env bash
2
  set -e
3
 
4
+ # -------------------------------------------------
5
  # 1️⃣ 目录准备
6
+ # -------------------------------------------------
7
  mkdir -p /root/.openclaw/agents/main/sessions
8
  mkdir -p /root/.openclaw/credentials
9
  mkdir -p /root/.openclaw/sessions
10
  mkdir -p /root/.openclaw/config/plugins.entries
11
  mkdir -p /root/.openclaw/openclaw-weixin/accounts # 确保 accounts 目录存在
12
 
13
+ # -------------------------------------------------
14
  # 2️⃣ 恢复历史备份(如果有)
15
+ # -------------------------------------------------
16
+ python3 /app/sync.py restore || true # 若没有备份则不报错
17
 
18
+ # -------------------------------------------------
19
+ # 3️⃣ 处理 OpenAI API 地址(保持原有逻辑)
20
+ # -------------------------------------------------
21
  CLEAN_BASE=$(echo "$OPENAI_API_BASE" \
22
  | sed "s|/chat/completions||g" \
23
  | sed "s|/v1/|/v1|g" \
24
  | sed "s|/v1$|/v1|g")
25
 
26
+ # -------------------------------------------------
27
  # 4️⃣ 生成 OpenClaw 主配置文件
28
+ # -------------------------------------------------
29
  cat > /root/.openclaw/openclaw.json <<EOF
30
  {
31
  "models": {
 
58
  }
59
  EOF
60
 
61
+ # -------------------------------------------------
62
+ # 5️⃣ 微信 token 持久化处理(复制持久化的 accounts 目录)
63
+ # -------------------------------------------------
64
+ mkdir -p /workspace/openclaw_data/weixin_accounts
65
+ if [[ -d /workspace/openclaw_data/weixin_accounts ]]; then
66
+ cp -r /workspace/openclaw_data/weixin_accounts/* /root/.openclaw/openclaw-weixin/accounts/
67
+ fi
68
 
69
+ # -------------------------------------------------
70
+ # 6️⃣ 只在第一次启动时安装微信插件(后续启动不再执行)
71
+ # -------------------------------------------------
72
  npx -y @tencent-weixin/openclaw-weixin-cli@latest install --no-restart || true
73
 
74
+ # -------------------------------------------------
 
75
  # 7️⃣ 启动定时备份(每 1 小时一次)
76
+ # -------------------------------------------------
77
  ( while true; do
78
  sleep 3600
79
  python3 /app/sync.py backup
80
  done ) &
81
 
82
+ # -------------------------------------------------
83
+ # 8️⃣(建议)去掉 doctor --fix,防止 token 被删除
84
+ # -------------------------------------------------
85
+ # openclaw doctor --fix # 如需自检请手动执行此行
86
 
87
+ # -------------------------------------------------
88
+ # 9️⃣ 启动网关(前台运行,确保容器不会退出)
89
+ # -------------------------------------------------
90
  exec openclaw gateway run --port $PORT