From 7c9eb82a6fff38ebdabe561b02573591dd0442d9 Mon Sep 17 00:00:00 2001 From: Gloridust Date: Sun, 14 Jun 2026 18:52:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(v1.2.0):=20=E6=97=A7=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E6=97=A0=20app-ctl.sh=20=E6=97=B6=E5=9B=9E=E9=80=80=20wechat-c?= =?UTF-8?q?tl.sh=EF=BC=88=E4=BF=AE=E5=BE=AE=E4=BF=A1=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E8=AF=AF=E6=8A=A5=E6=9C=AA=E5=AE=89=E8=A3=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 多应用分发对所有实例调 /woc/app-ctl.sh,但升级前的旧容器镜像里没有该脚本 → exec 失败 → wechatStatus 兜底成"未安装",已装微信的老实例全变"待安装"。triggerWechat/wechatStatus 改为 bash -c:有 app-ctl.sh 则按 appType 分发,无则回退老的 wechat-ctl.sh(旧实例皆微信)。 老实例不升级也能正常显示/操作;升级到多应用镜像后自动走 app-ctl 分发。 Co-Authored-By: Claude Opus 4.8 --- panel/server/src/docker.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/panel/server/src/docker.ts b/panel/server/src/docker.ts index 59826a9..252ff7e 100644 --- a/panel/server/src/docker.ts +++ b/panel/server/src/docker.ts @@ -409,12 +409,15 @@ async function execCapture(inst: Instance, cmd: string[]): Promise { }); } -// 触发下载/安装(detached,立即返回,后台下载)。按实例 appType 分发: -// app-ctl.sh wechat → 委托回 wechat-ctl.sh(微信逻辑零改动);telegram 等各自实现。 +// 触发下载/安装(detached,立即返回,后台下载)。按实例 appType 分发:app-ctl.sh wechat → 委托回 +// wechat-ctl.sh;telegram 等各自实现。兼容旧容器(升级前镜像里没有 /woc/app-ctl.sh):有则用之,无则 +// 回退老的 wechat-ctl.sh(旧实例都是微信)。appType 取值受 instanceAppType 约束,可安全内插进 shell。 export async function triggerWechat(inst: Instance, cmd: 'install' | 'update'): Promise { const c = docker.getContainer(inst.containerName); + const at = instanceAppType(inst); + const action = cmd === 'update' ? 'update' : 'install'; const exec = await c.exec({ - Cmd: ['/woc/app-ctl.sh', instanceAppType(inst), cmd === 'update' ? 'update' : 'install'], + Cmd: ['bash', '-c', `if [ -x /woc/app-ctl.sh ]; then /woc/app-ctl.sh ${at} ${action}; else /woc/wechat-ctl.sh ${action}; fi`], AttachStdout: false, AttachStderr: false, User: 'abc', @@ -435,7 +438,13 @@ const DEFAULT_STATUS: WechatStatus = { phase: 'idle', percent: 0, installed: fal export async function wechatStatus(inst: Instance): Promise { try { - const raw = await execCapture(inst, ['/woc/app-ctl.sh', instanceAppType(inst), 'status']); + // 兼容旧容器(无 /woc/app-ctl.sh):有则按 appType 取状态,无则回退老的 wechat-ctl.sh(旧实例皆微信)。 + const at = instanceAppType(inst); + const raw = await execCapture(inst, [ + 'bash', + '-c', + `if [ -x /woc/app-ctl.sh ]; then /woc/app-ctl.sh ${at} status; else /woc/wechat-ctl.sh status; fi`, + ]); const json = JSON.parse(raw.trim()); return { ...DEFAULT_STATUS, ...json }; } catch {