Files
LocalNav/scripts/install.ps1
T
dekun f508f210f9 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>
2026-07-12 12:01:01 +08:00

32 lines
1.1 KiB
PowerShell

# LocalNav 交互式部署管理(无需预先克隆)
# 用法:.\scripts\install.ps1
$ErrorActionPreference = "Stop"
$DefaultRepo = "https://git.bz121.com/dekun/LocalNav.git"
$RawBase = "$($DefaultRepo -replace '\.git$','')/raw/main/scripts"
function Need-Cmd($name) {
if (-not (Get-Command $name -ErrorAction SilentlyContinue)) {
Write-Error "[FAIL] 未找到 $name,请先安装"
}
}
Need-Cmd python
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$navctlPy = Join-Path $scriptDir "navctl.py"
if (-not (Test-Path $navctlPy)) {
$tmpDir = Join-Path $env:TEMP ("localnav-" + [guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null
Write-Host "[OK] 正在下载部署管理脚本..."
Invoke-WebRequest -Uri "$RawBase/navctl.py" -OutFile (Join-Path $tmpDir "navctl.py")
Invoke-WebRequest -Uri "$RawBase/nav_common.py" -OutFile (Join-Path $tmpDir "nav_common.py")
$env:PYTHONPATH = "$tmpDir;$env:PYTHONPATH"
python (Join-Path $tmpDir "navctl.py") @args
Remove-Item -Recurse -Force $tmpDir
exit $LASTEXITCODE
}
python $navctlPy @args