diff --git a/scripts/update.sh b/scripts/update.sh index b223366..6e190f4 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -13,6 +13,10 @@ # 9. 全量验证 # # 前提:已执行过 install.sh 完成初始部署 +# +# 环境变量(可选): +# XUQM_NONINTERACTIVE=1 非交互模式(CI/Jenkins 自动化使用) +# XUQM_PULL_IMAGES=y 非交互模式下是否拉取最新镜像(默认 y) set -euo pipefail @@ -437,9 +441,15 @@ fi # --------------------------------------------------------------------------- log "拉取最新镜像(可选)" -read -rp " 是否拉取最新镜像?(y/N): " _pull_choice +if [ "${XUQM_NONINTERACTIVE:-0}" = "1" ]; then + _pull_choice="${XUQM_PULL_IMAGES:-y}" + printf ' [非交互] 拉取最新镜像: %s\n' "$_pull_choice" +else + read -rp " 是否拉取最新镜像?(y/N): " _pull_choice +fi if [ "${_pull_choice:-n}" = "y" ] || [ "${_pull_choice:-n}" = "Y" ]; then - _REGISTRY_HOST="${REGISTRY_HOST:-}" + # 从 REGISTRY (registry.host/namespace/...) 中提取主机部分 + _REGISTRY_HOST="${REGISTRY_HOST:-$(printf '%s' "${REGISTRY:-}" | cut -d'/' -f1)}" _REGISTRY_USER="${REGISTRY_USER:-}" _REGISTRY_PASSWORD="${REGISTRY_PASSWORD:-}" @@ -501,7 +511,7 @@ printf ' 等待 tenant-service 就绪' _healthy=0 for i in $(seq 1 40); do _code="$(curl -skL --noproxy '*' -o /dev/null -w '%{http_code}' --max-time 4 \ - "http://127.0.0.1:11224/actuator/health" 2>/dev/null || echo 000)" + "http://127.0.0.1:${SVC_PORT_TENANT:-11224}/actuator/health" 2>/dev/null || echo 000)" if [ "$_code" = "200" ]; then printf '\n' ok "tenant-service 健康 (HTTP 200)" @@ -523,7 +533,7 @@ log "处理积压的服务开通申请" if [ "$_healthy" -eq 1 ]; then _approve_resp="$(curl -sk --noproxy '*' -X POST \ - "http://127.0.0.1:11224/api/private/admin/approve-pending-requests" \ + "http://127.0.0.1:${SVC_PORT_TENANT:-11224}/api/private/admin/approve-pending-requests" \ --max-time 10 2>/dev/null || true)" _approved="$(printf '%s' "$_approve_resp" | \ python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('data',{}).get('approved',0))" \