Add install script for clone-first one-click deployment.
Prompt for repo URL and install directory, auto git clone, then run project setup. Keep deploy.py for in-repo updates only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+81
-28
@@ -54,9 +54,12 @@
|
||||
├── .env # 本地配置(自建,勿提交 Git)
|
||||
├── ecosystem.config.cjs # PM2 守护进程配置
|
||||
├── scripts/
|
||||
│ ├── deploy.py # 一键部署(环境检测、生成 .env)
|
||||
│ ├── deploy.sh # Linux/macOS 封装
|
||||
│ ├── deploy.ps1 # Windows 封装
|
||||
│ ├── install.py # 一键安装(输入仓库地址,自动克隆 + 部署)
|
||||
│ ├── install.sh # Linux/macOS 安装封装(支持 curl | bash)
|
||||
│ ├── install.ps1 # Windows 安装封装
|
||||
│ ├── deploy.py # 项目内更新部署(需已在仓库目录)
|
||||
│ ├── deploy.sh # 项目内更新封装
|
||||
│ ├── deploy.ps1 # 项目内更新封装
|
||||
│ └── cleanup_gate_scout.py # 可选:清理旧「Gate 扫单」分组
|
||||
├── nav_local.db # SQLite 数据库(首次成功运行后生成,勿手误提交到公开仓库)
|
||||
├── static/
|
||||
@@ -74,26 +77,54 @@
|
||||
|
||||
---
|
||||
|
||||
## 五、一键部署(推荐)
|
||||
## 五、一键部署(推荐,无需预先克隆)
|
||||
|
||||
项目提供跨平台部署脚本,自动完成环境检测、虚拟环境创建、依赖安装、`.env` 生成与 `NAV_SECRET_KEY` 写入。
|
||||
在**新机器**上无需先 `git clone`,运行安装脚本后按提示输入仓库地址即可自动克隆并完成部署。
|
||||
|
||||
### 5.1 首次安装
|
||||
|
||||
```bash
|
||||
# Linux / macOS
|
||||
bash scripts/deploy.sh
|
||||
|
||||
# Windows PowerShell
|
||||
.\scripts\deploy.ps1
|
||||
|
||||
# 或直接
|
||||
python scripts/deploy.py
|
||||
# Linux / macOS(一条命令,从远程拉取安装脚本)
|
||||
curl -fsSL https://git.bz121.com/dekun/LocalNav/raw/main/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
**脚本行为:**
|
||||
也可将 `install.sh` / `install.py` 拷贝到本机后执行:
|
||||
|
||||
```bash
|
||||
bash scripts/install.sh
|
||||
# 或
|
||||
python3 scripts/install.py
|
||||
```
|
||||
|
||||
**Windows PowerShell:**
|
||||
|
||||
```powershell
|
||||
.\scripts\install.ps1
|
||||
```
|
||||
|
||||
**交互提示:**
|
||||
|
||||
| 提示项 | 默认值 |
|
||||
|--------|--------|
|
||||
| Git 仓库地址 | `https://git.bz121.com/dekun/LocalNav.git` |
|
||||
| 安装目录 | Linux:`/opt/LocalNav`;Windows:`./LocalNav` |
|
||||
|
||||
**非交互(使用默认值):**
|
||||
|
||||
```bash
|
||||
python3 scripts/install.py -y
|
||||
python3 scripts/install.py --repo https://git.bz121.com/dekun/LocalNav.git --dir /opt/LocalNav
|
||||
```
|
||||
|
||||
环境变量可跳过提问:`NAV_INSTALL_REPO`、`NAV_INSTALL_DIR`。
|
||||
|
||||
### 5.2 自动完成的步骤
|
||||
|
||||
| 步骤 | 说明 |
|
||||
|------|------|
|
||||
| 环境检测 | Python 3.10+、pip;可选检测 git、pm2 |
|
||||
| 环境检测 | Python 3.10+、git(必填)、pip |
|
||||
| 克隆代码 | `git clone` 到指定目录;若目录已是本项目则 `git pull` |
|
||||
| 虚拟环境 | 创建 `.venv` 并 `pip install -r requirements.txt` |
|
||||
| 生成 `.env` | 从 `.env.example` 复制(若不存在) |
|
||||
| `NAV_SECRET_KEY` | 若为空则自动生成 64 位 hex |
|
||||
| 默认账号 | `NAV_ADMIN_USERNAME=admin`、`NAV_ADMIN_PASSWORD=admin123` |
|
||||
@@ -102,6 +133,14 @@ python scripts/deploy.py
|
||||
|
||||
**注意:** 脚本不会覆盖 `.env` 中已有的 `NAV_SECRET_KEY` 等配置。生产环境部署后请尽快登录并在「系统设置」中修改密码。
|
||||
|
||||
### 5.3 已安装后的更新
|
||||
|
||||
```bash
|
||||
cd /opt/LocalNav
|
||||
git pull
|
||||
python3 scripts/deploy.py # 或 bash scripts/deploy.sh
|
||||
```
|
||||
|
||||
部署完成后启动:
|
||||
|
||||
```bash
|
||||
@@ -226,7 +265,7 @@ http://<本机局域网IP>:5070
|
||||
- 密码:**`admin123`**
|
||||
- 一个名为 **「默认分组」** 的空分组。
|
||||
2. 控制台会打印一行提示(内容大意:默认账号仅内网使用,请尽快修改)。
|
||||
3. 一键部署脚本 `scripts/deploy.py` 会写入相同的默认账号;若 `.env` 中已有 `NAV_ADMIN_USERNAME` / `NAV_ADMIN_PASSWORD` 则以其为准。
|
||||
3. 一键安装脚本 `scripts/install.py` 会写入相同的默认账号;若 `.env` 中已有 `NAV_ADMIN_USERNAME` / `NAV_ADMIN_PASSWORD` 则以其为准。
|
||||
|
||||
**安全建议(强烈)**:
|
||||
|
||||
@@ -360,17 +399,19 @@ sudo apt install -y python3 python3-venv python3-pip git
|
||||
|
||||
(若已安装 Python 3、venv 与 git,可跳过。)
|
||||
|
||||
### 10.2 克隆项目并安装依赖
|
||||
### 10.2 一键安装(推荐)
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /opt
|
||||
cd /opt
|
||||
sudo git clone https://git.bz121.com/dekun/LocalNav.git
|
||||
cd /opt/LocalNav
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -U pip
|
||||
pip install -r requirements.txt -i https://pypi.org/simple
|
||||
sudo apt install -y python3 python3-venv python3-pip git # 若 10.1 已装可跳过
|
||||
curl -fsSL https://git.bz121.com/dekun/LocalNav/raw/main/scripts/install.sh | bash
|
||||
# 按提示输入仓库地址(直接回车用默认)与安装目录(建议 /opt/LocalNav)
|
||||
```
|
||||
|
||||
或手动执行:
|
||||
|
||||
```bash
|
||||
curl -fsO https://git.bz121.com/dekun/LocalNav/raw/main/scripts/install.py
|
||||
sudo python3 install.py --repo https://git.bz121.com/dekun/LocalNav.git --dir /opt/LocalNav
|
||||
```
|
||||
|
||||
后续更新代码:
|
||||
@@ -378,11 +419,23 @@ pip install -r requirements.txt -i https://pypi.org/simple
|
||||
```bash
|
||||
cd /opt/LocalNav
|
||||
git pull
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt -i https://pypi.org/simple
|
||||
sudo systemctl restart nav-site
|
||||
python3 scripts/deploy.py
|
||||
pm2 restart nav-site # 或 systemctl restart nav-site
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>手动克隆安装(旧方式,不推荐)</summary>
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /opt
|
||||
cd /opt
|
||||
sudo git clone https://git.bz121.com/dekun/LocalNav.git
|
||||
cd /opt/LocalNav
|
||||
python3 scripts/deploy.py
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### 10.3 配置密钥(必做)
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user