f508f210f9
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>
35 lines
1001 B
Bash
35 lines
1001 B
Bash
#!/usr/bin/env bash
|
|
# LocalNav 交互式部署管理(无需预先克隆)
|
|
# 用法:
|
|
# curl -fsSL https://git.bz121.com/dekun/LocalNav/raw/main/scripts/install.sh | bash
|
|
# bash install.sh
|
|
set -euo pipefail
|
|
|
|
DEFAULT_REPO="https://git.bz121.com/dekun/LocalNav.git"
|
|
RAW_BASE="${DEFAULT_REPO%.git}/raw/main/scripts"
|
|
|
|
need_cmd() {
|
|
command -v "$1" >/dev/null 2>&1 || {
|
|
echo "[FAIL] 未找到 $1,请先安装" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
need_cmd python3
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd || true)"
|
|
NAVCTL_PY="${SCRIPT_DIR}/navctl.py"
|
|
|
|
if [ ! -f "$NAVCTL_PY" ]; then
|
|
TMP_DIR="$(mktemp -d)"
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
echo "[OK] 正在下载部署管理脚本..."
|
|
curl -fsSL "${RAW_BASE}/navctl.py" -o "${TMP_DIR}/navctl.py"
|
|
curl -fsSL "${RAW_BASE}/nav_common.py" -o "${TMP_DIR}/nav_common.py"
|
|
export PYTHONPATH="${TMP_DIR}:${PYTHONPATH:-}"
|
|
exec python3 "${TMP_DIR}/navctl.py" "$@"
|
|
fi
|
|
|
|
cd "$(dirname "$NAVCTL_PY")"
|
|
exec python3 "$NAVCTL_PY" "$@"
|