Add interactive navctl menu for install, uninstall, and update.

Provide navctl.py with a numbered menu, persist install path in config, and support curl bootstrap without pre-cloning the repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-12 12:01:01 +08:00
parent fc23a95e5c
commit f508f210f9
11 changed files with 608 additions and 278 deletions
+34 -21
View File
@@ -10,44 +10,57 @@ Flask + SQLite 的局域网导航聚合:左侧分组与服务列表,右侧 i
## 一键部署(无需预先克隆)
在**空目录或新服务器**上,只需运行安装脚本,按提示输入 Git 仓库地址即可自动克隆并完成部署
运行安装脚本后会进入**交互菜单**
```
==================================================
LocalNav 部署管理
==================================================
安装目录: /opt/LocalNav
服务状态: pm2 online
--------------------------------------------------
1 一键部署安装
2 一键卸载
3 更新
0 退出
--------------------------------------------------
请选择:
```
```bash
# Linux / macOS(推荐:一条命令,无需先 git clone)
curl -fsSL https://git.bz121.com/dekun/LocalNav/raw/main/scripts/install.sh | bash
# 或本地已有 install 脚本时
# 或本地执行
bash scripts/install.sh
python scripts/install.py
python scripts/navctl.py
# Windows PowerShell
.\scripts\install.ps1
```
运行后会提示:
**菜单功能:**
1. **Git 仓库地址**(默认 `https://git.bz121.com/dekun/LocalNav.git`
2. **安装目录**Linux 默认 `/opt/LocalNav`Windows 默认 `./LocalNav`
| 选项 | 说明 |
|------|------|
| 1 安装 | 输入仓库地址 → 自动 `git clone` → 安装依赖 → 生成 `.env` → pm2 启动 |
| 2 卸载 | 停止 pm2/systemd 服务;可选删除整个安装目录(含数据库) |
| 3 更新 | `git pull` → 重新部署 → 自动重启服务 |
| 0 退出 | 退出菜单 |
非交互命令:
```bash
python scripts/navctl.py install -y
python scripts/navctl.py update --dir /opt/LocalNav
python scripts/navctl.py uninstall --dir /opt/LocalNav
```
随后自动:`git clone` → 创建虚拟环境 → 安装依赖 → 生成 `.env``NAV_SECRET_KEY`**自动 pm2 启动**(若已安装 pm2)。
非交互安装(使用默认值):
```bash
python scripts/install.py -y
# 或指定参数
python scripts/install.py --repo https://git.bz121.com/dekun/LocalNav.git --dir /opt/LocalNav
```
**默认登录:** `admin` / `admin123`(生产环境请尽快在「系统设置」中修改密码)
**已安装后的更新**(在项目目录内):
```bash
cd /opt/LocalNav
git pull
python scripts/deploy.py # 或 bash scripts/deploy.sh
```
**已安装后的更新** 重新运行 `install.sh` 选菜单 **3**,或执行 `python scripts/navctl.py update`
配置:将 `.env.example` 复制为 `.env` 并填写变量(与 `app.py` 同目录);详见说明文档「环境变量与 `.env`」一节。