(msg: Api.Message)
| 330 | |
| 331 | await execAsync(`systemctl stop openlist || true`); |
| 332 | await execAsync(`cp "${installPath}/openlist" /tmp/openlist.bak || true`); |
| 333 | await execAsync(`tar zxf "${tarPath}" -C "${installPath}/"`); |
| 334 | await execAsync(`chmod +x "${installPath}/openlist"`); |
| 335 | await execAsync(`systemctl restart openlist`); |
| 336 | |
| 337 | const { stdout: verOut } = await execAsync( |
| 338 | `bash -lc '"${installPath}/openlist" version 2>&1 || true'` |
| 339 | ); |
| 340 | const verMatch = verOut.match(/Version:\s*([^\s]+)/); |
| 341 | const version = verMatch ? verMatch[1] : ""; |
| 342 | await msg.edit({ text: `更新完成${version ? `,版本: ${version}` : ""}` }); |
| 343 | } catch (error: any) { |
| 344 | await msg.edit({ text: `更新失败: ${error?.message || error}` }); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | private async handleUninstall(msg: Api.Message) { |
| 349 | try { |
| 350 | if (process.platform !== "linux") { |
| 351 | await msg.edit({ text: "仅支持 Linux(systemd)环境" }); |
| 352 | return; |
| 353 | } |
| 354 | |
| 355 | const installPath = await this.detectInstalledPath(); |
no test coverage detected