(msg: Api.Message)
| 272 | ip = (stdout || "").trim(); |
| 273 | } catch {} |
| 274 | |
| 275 | const lines: string[] = []; |
| 276 | lines.push("安装完成"); |
| 277 | if (version) lines.push(`版本: ${version}`); |
| 278 | lines.push(`目录: ${installPath}`); |
| 279 | lines.push(`访问: http://${ip || "服务器IP"}:5244/`); |
| 280 | if (username && password) { |
| 281 | lines.push(`账号: ${username}`); |
| 282 | lines.push(`密码: ${password}`); |
| 283 | } |
| 284 | await msg.edit({ text: lines.join("\n") }); |
| 285 | } catch (error: any) { |
| 286 | await msg.edit({ text: `安装失败: ${htmlEscape(error?.message || error)}`, parseMode: "html" }); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | private async handleUpdate(msg: Api.Message) { |
| 291 | try { |
| 292 | if (process.platform !== "linux") { |
| 293 | await msg.edit({ text: "仅支持 Linux(systemd)环境" }); |
| 294 | return; |
| 295 | } |
| 296 | |
| 297 | const hasSystemd = await this.hasCmd("systemctl"); |
| 298 | const hasCurl = await this.hasCmd("curl"); |
| 299 | const hasTar = await this.hasCmd("tar"); |
| 300 | if (!hasSystemd || !hasCurl || !hasTar) { |
| 301 | const missing = [ |
| 302 | !hasSystemd ? "systemctl" : "", |
| 303 | !hasCurl ? "curl" : "", |
| 304 | !hasTar ? "tar" : "", |
| 305 | ] |
| 306 | .filter(Boolean) |
| 307 | .join(", "); |
| 308 | await msg.edit({ text: `缺少依赖:${missing}` }); |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | const arch = this.mapArch(process.arch); |
| 313 | if (!arch) { |
| 314 | await msg.edit({ text: `暂不支持当前架构:${process.arch}` }); |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | const installPath = await this.detectInstalledPath(); |
| 319 | if (!(await this.fileExists(`${installPath}/openlist`))) { |
| 320 | await msg.edit({ text: `未检测到已安装版本。可使用:${commandName} install` }); |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | await msg.edit({ text: "开始更新..." }); |
| 325 | const tarPath = "/tmp/openlist.tar.gz"; |
| 326 | const url = `${GH_BASE_DOWNLOAD}/openlist-linux-musl-${arch}.tar.gz`; |
| 327 | await execAsync( |
| 328 | `curl -L --connect-timeout 10 --retry 3 --retry-delay 3 "${url}" -o "${tarPath}"` |
| 329 | ); |
| 330 | |
| 331 | await execAsync(`systemctl stop openlist || true`); |
no test coverage detected