From 72e46cef32e70aed40eb59d219ba4a0cb7b3da26 Mon Sep 17 00:00:00 2001 From: Nexus Agent Date: Sat, 6 Jun 2026 23:21:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E5=8D=87=E7=BA=A7=E5=90=8E?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E9=AA=8C=E6=94=B6=E4=B8=8E=20verify=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 验收检查容器内 round6/7 特性;修复 host.docker.internal 引号;nx verify 与升级后自动验收。 Co-authored-by: Cursor --- deploy/nexus-1panel.sh | 8 ++++ deploy/nx | 11 +++++ deploy/verify-1panel-install-wizard.sh | 43 ++++++++++++++++++- ...-menu-audit-round8-image-verify-upgrade.md | 30 +++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/2026-06-06-nx-god-menu-audit-round8-image-verify-upgrade.md diff --git a/deploy/nexus-1panel.sh b/deploy/nexus-1panel.sh index c029301f..391f4d6b 100755 --- a/deploy/nexus-1panel.sh +++ b/deploy/nexus-1panel.sh @@ -1217,6 +1217,14 @@ cmd_upgrade() { suggest_ops_cron "$NEXUS_ROOT" fi fi + local vcname + vcname="$(nexus_container_name)" + if [[ -n "$vcname" ]] && nexus_container_has_install_lock "$vcname" \ + && [[ -x "$NEXUS_ROOT/deploy/verify-1panel-install-wizard.sh" ]]; then + step "升级后验收..." + NEXUS_ROOT="$NEXUS_ROOT" bash "$NEXUS_ROOT/deploy/verify-1panel-install-wizard.sh" || \ + warn "验收脚本报告 FAIL — 见上方输出" + fi } cmd_check() { diff --git a/deploy/nx b/deploy/nx index db459d32..eb094ce1 100755 --- a/deploy/nx +++ b/deploy/nx @@ -270,6 +270,7 @@ menu_main() { [8] 重建镜像并启动(--build nexus) [9] 备份 MySQL [e] 安装巡检/备份 cron(health_monitor + db_backup) + [v] 1Panel 安装/运维验收脚本 ── 其它 ── [a] 检查 Git 是否有更新 @@ -348,6 +349,11 @@ EOF ops_install_cron pause_enter ;; + v|V) + require_root + bash "${NX_DIR}/verify-1panel-install-wizard.sh" + pause_enter + ;; a|A) require_root cmd_check @@ -413,6 +419,10 @@ nx_main() { require_root ops_install_cron ;; + verify) + require_root + bash "${NX_DIR}/verify-1panel-install-wizard.sh" + ;; -h|--help) cat </dev/null || true)" - if [[ -n "$db_host" && "$db_host" != host.docker.internal ]]; then + if [[ -n "$db_host" && "$db_host" != "host.docker.internal" ]]; then pass "步骤 3 预填 db_host=$db_host" - elif [[ "$db_host" == host.docker.internal ]]; then + elif [[ "$db_host" == "host.docker.internal" ]]; then fail "步骤 3 仍预填 host.docker.internal" info "修复: nx update --no-cache(需 b25d079+)" fi @@ -315,6 +315,44 @@ print((d.get('docker_defaults') or {}).get('db_host','')) fi } +check_container_image_features() { + [[ -n "${NEXUS_CONTAINER:-}" ]] || return 0 + local host_sha py_ok html_file html_ok host_root_ok + host_sha="$(git -C "$NEXUS_ROOT" rev-parse --short HEAD 2>/dev/null || echo unknown)" + pass "宿主机 Git: $host_sha" + + if docker exec "$NEXUS_CONTAINER" grep -q '_host_deploy_root' /app/server/api/install.py 2>/dev/null; then + pass "容器 install.py 含 host_deploy_root(round6+)" + py_ok=1 + else + warn "容器 install.py 较旧 — 需 nx update 重建镜像" + fi + + html_file="/app/web/app/install.html" + if docker exec "$NEXUS_CONTAINER" test -f /app/web/app/install.html.bak 2>/dev/null; then + html_file="/app/web/app/install.html.bak" + fi + if docker exec "$NEXUS_CONTAINER" grep -q 'install_ops_cron' "$html_file" 2>/dev/null; then + pass "容器 install.html 含 Layer 3 cron 指引(round7+)" + html_ok=1 + else + warn "容器 install.html 较旧 — 需 nx update 重建镜像" + fi + + host_root_ok="$(docker exec "$NEXUS_CONTAINER" printenv NEXUS_HOST_ROOT 2>/dev/null || true)" + if [[ -n "$host_root_ok" ]]; then + pass "NEXUS_HOST_ROOT=$host_root_ok" + else + warn "容器未注入 NEXUS_HOST_ROOT — nx update 重建后可修复" + fi + + if [[ -n "${py_ok:-}" && -n "${html_ok:-}" ]]; then + info "镜像与宿主机代码特性对齐(重建后验收)" + else + info "修复: cd $NEXUS_ROOT && sudo nx update" + fi +} + check_openresty_hint() { local domain code domain="$(grep -E '^NEXUS_API_BASE_URL=' "$ENV_PROD" 2>/dev/null | sed 's|.*https\?://||;s|/.*||' || echo api.synaglobal.vip)" @@ -376,6 +414,7 @@ main() { check_install_api || true check_ops_cron || true check_mysql_backup || true + check_container_image_features || true check_openresty_hint || true print_next_steps diff --git a/docs/changelog/2026-06-06-nx-god-menu-audit-round8-image-verify-upgrade.md b/docs/changelog/2026-06-06-nx-god-menu-audit-round8-image-verify-upgrade.md new file mode 100644 index 00000000..1ced8ea8 --- /dev/null +++ b/docs/changelog/2026-06-06-nx-god-menu-audit-round8-image-verify-upgrade.md @@ -0,0 +1,30 @@ +# nx 上帝菜单巡检第八轮 — 镜像版本验收 + 生产 nx update + +| 项 | 内容 | +|----|------| +| 日期 | 2026-06-06 | +| 动机 | round6/7 改动在宿主机 git 已更新但容器镜像未重建;验收脚本 `host.docker.internal` 比较未加引号;缺升级后自动验收 | + +## 变更摘要 + +1. **verify-1panel-install-wizard.sh**:修复 `host.docker.internal` bash 引号 bug;新增 `check_container_image_features`(install.py / install.html / NEXUS_HOST_ROOT)。 +2. **nexus-1panel.sh upgrade**:已锁定环境升级成功后自动跑验收脚本。 +3. **nx**:菜单 `[v]` / 子命令 `nx verify` 调用验收脚本。 + +## 涉及文件 + +- `deploy/verify-1panel-install-wizard.sh` +- `deploy/nexus-1panel.sh` +- `deploy/nx` + +## 迁移 / 重启 + +- 需 `sudo nx update` 重建镜像以使 round6/7 容器内代码生效。 + +## 验证 + +```bash +bash -n deploy/verify-1panel-install-wizard.sh +sudo nx verify +sudo nx update --no-backup # 重建后 check_container_image_features 应全 PASS +```