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:
+9
-17
@@ -31,31 +31,23 @@ unset _script_src
|
|||||||
|
|
||||||
set -u
|
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() {
|
repo_ready() {
|
||||||
[[ -f "${1}/deploy/setup_env.sh" && -f "${1}/deploy/manage.sh" ]]
|
[[ -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() {
|
bootstrap_repo() {
|
||||||
if repo_ready "${INSTALL_ROOT}"; then
|
if repo_ready "${INSTALL_ROOT}"; then
|
||||||
REPO_ROOT="${INSTALL_ROOT}"
|
REPO_ROOT="${INSTALL_ROOT}"
|
||||||
DEPLOY_DIR="${REPO_ROOT}/deploy"
|
DEPLOY_DIR="${REPO_ROOT}/deploy"
|
||||||
LIB_DIR="${DEPLOY_DIR}/lib"
|
LIB_DIR="${DEPLOY_DIR}/lib"
|
||||||
|
sync_repo_if_present "${REPO_ROOT}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [[ -n "${REPO_ROOT}" ]] && repo_ready "${REPO_ROOT}"; then
|
if [[ -n "${REPO_ROOT}" ]] && repo_ready "${REPO_ROOT}"; then
|
||||||
@@ -87,6 +79,7 @@ bootstrap_repo() {
|
|||||||
fi
|
fi
|
||||||
mkdir -p "$(dirname "${INSTALL_ROOT}")"
|
mkdir -p "$(dirname "${INSTALL_ROOT}")"
|
||||||
git clone -b "${GIT_BRANCH}" "${GIT_URL}" "${INSTALL_ROOT}"
|
git clone -b "${GIT_BRANCH}" "${GIT_URL}" "${INSTALL_ROOT}"
|
||||||
|
# clone 后用仓库内脚本 + 终端 stdin(管道已 EOF)
|
||||||
exec bash "${INSTALL_ROOT}/deploy/manage.sh" "$@" </dev/tty
|
exec bash "${INSTALL_ROOT}/deploy/manage.sh" "$@" </dev/tty
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,5 +146,4 @@ main_menu() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
reexec_with_tty_if_needed "$@"
|
|
||||||
main_menu "$@"
|
main_menu "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user