#!/usr/bin/env bash # 生产冒烟(T3):部署后三断言——robots 带 Sitemap / sitemap-index 可达 / 首页无 x-robots-tag # 用法:./prod-smoke.sh [BASE_URL](默认 https://wait4x.online;构建机对 staging 传 http://127.0.0.1:18743) # 任一断言失败 exit 1;robots 缺失常见于 SEO 解封前(T1 未落),会明确报 FAIL 而非静默 set -u BASE="${1:-${SMOKE_BASE:-https://wait4x.online}}" fail=0 robots="$(curl -fsS --max-time 15 "${BASE}/robots.txt" 2>/dev/null)" \ && grep -q 'Sitemap:' <<<"$robots" \ && echo "[smoke] robots.txt 200 含 Sitemap ✓" \ || { echo "[smoke] FAIL robots.txt 缺失/无 Sitemap 行:${BASE}/robots.txt"; fail=1; } curl -fsS --max-time 15 -o /dev/null "${BASE}/sitemap-index.xml" \ && echo "[smoke] sitemap-index 200 ✓" \ || { echo "[smoke] FAIL sitemap-index 不可达:${BASE}/sitemap-index.xml"; fail=1; } # x-robots-tag 出现即 FAIL(noindex 头会废掉整站收录,SEO 解封的反面) if curl -fsS --max-time 15 -I "${BASE}/" | grep -qi 'x-robots-tag'; then echo "[smoke] FAIL 首页响应头含 x-robots-tag"; fail=1 else echo "[smoke] 首页无 x-robots-tag ✓" fi exit $fail