Pull latest deploy scripts when repo exists before showing curl-pipe menu.

Avoids sourcing stale lib/common.sh from an older clone after curl | bash.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-12 12:37:15 +08:00
parent acb61a413b
commit 96b5096284
+9 -17
View File
@@ -31,31 +31,23 @@ unset _script_src
set -u
# curl | bash: stdin 为管道,clone 后或已有仓库时改从终端读入
reexec_with_tty_if_needed() {
if [[ -t 0 ]]; then
return 0
fi
local script=""
if [[ -f "${INSTALL_ROOT}/deploy/manage.sh" ]]; then
script="${INSTALL_ROOT}/deploy/manage.sh"
elif [[ -n "${DEPLOY_DIR}" && -f "${DEPLOY_DIR}/manage.sh" ]]; then
script="${DEPLOY_DIR}/manage.sh"
fi
if [[ -n "${script}" ]]; then
exec bash "${script}" "$@" </dev/tty
fi
}
repo_ready() {
[[ -f "${1}/deploy/setup_env.sh" && -f "${1}/deploy/manage.sh" ]]
}
sync_repo_if_present() {
local root="$1"
if [[ -d "${root}/.git" ]] && command -v git >/dev/null 2>&1; then
git -C "${root}" pull -q --ff-only 2>/dev/null || true
fi
}
bootstrap_repo() {
if repo_ready "${INSTALL_ROOT}"; then
REPO_ROOT="${INSTALL_ROOT}"
DEPLOY_DIR="${REPO_ROOT}/deploy"
LIB_DIR="${DEPLOY_DIR}/lib"
sync_repo_if_present "${REPO_ROOT}"
return 0
fi
if [[ -n "${REPO_ROOT}" ]] && repo_ready "${REPO_ROOT}"; then
@@ -87,6 +79,7 @@ bootstrap_repo() {
fi
mkdir -p "$(dirname "${INSTALL_ROOT}")"
git clone -b "${GIT_BRANCH}" "${GIT_URL}" "${INSTALL_ROOT}"
# clone 后用仓库内脚本 + 终端 stdin(管道已 EOF)
exec bash "${INSTALL_ROOT}/deploy/manage.sh" "$@" </dev/tty
}
@@ -153,5 +146,4 @@ main_menu() {
done
}
reexec_with_tty_if_needed "$@"
main_menu "$@"