From f04d1cea8c211e3c4bccf4995edb0b3710e57d70 Mon Sep 17 00:00:00 2001 From: xuqinmin12 Date: Fri, 12 Jun 2026 19:40:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20update.sh=20=E5=85=BC=E5=AE=B9=E7=8E=B0?= =?UTF-8?q?=E6=9C=89=E9=83=A8=E7=BD=B2=20=E2=80=94=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=A1=AC=E7=BC=96=E7=A0=8111224/REGISTRY=5FHOST/=E9=9D=9E?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=8B=89=E5=8F=96=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/update.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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))" \