diff --git a/scripts/ops/seo-unblock.sh b/scripts/ops/seo-unblock.sh index ee26740..455932e 100755 --- a/scripts/ops/seo-unblock.sh +++ b/scripts/ops/seo-unblock.sh @@ -20,7 +20,7 @@ for f in "$SITES"/*; do names=$(sudo grep -h "server_name" "$f" 2>/dev/null || true) [ -z "$names" ] && continue # 内部服务判定:server_name 含内部子域且不含主站裸域 - if echo "$names" | grep -qE "(git|api|oj|token|fc|latex|cpa)\.wait4x\.online" && ! echo "$names" | grep -qE "server_name[^;]*(^|[[:space:]])(www\.)?wait4x\.online([[:space:]];|$)" || echo "$names" | grep -qx "server_name wait4x.online;"; then + if sudo grep -q "include snippets/esa-origin-ssl" "$f" && ! echo "$names" | grep -qE "server_name[^;]*(^|[[:space:]])(www\.)?wait4x\.online([[:space:]];|$)" || echo "$names" | grep -qx "server_name wait4x.online;"; then sudo grep -q "X-Robots-Tag" "$f" || echo " [补回] $f:server 块加 add_header X-Robots-Tag noindex always;" fi # 博客主站判定:server_name 恰含裸域 @@ -41,7 +41,7 @@ sudo sed -i '/X-Robots-Tag noindex/d' "$SNIPPET" && echo " snippet 已剥 noind for f in "$SITES"/*; do names=$(sudo grep -h "server_name" "$f" 2>/dev/null || true) [ -z "$names" ] && continue - if echo "$names" | grep -qE "(git|api|oj|token|fc|latex|cpa)\.wait4x\.online" && ! echo "$names" | grep -qE "server_name[^;]*(^|[[:space:]])(www\.)?wait4x\.online([[:space:]];|$)" || echo "$names" | grep -qx "server_name wait4x.online;"; then + if sudo grep -q "include snippets/esa-origin-ssl" "$f" && ! echo "$names" | grep -qE "server_name[^;]*(^|[[:space:]])(www\.)?wait4x\.online([[:space:]];|$)" || echo "$names" | grep -qx "server_name wait4x.online;"; then if ! sudo grep -q "X-Robots-Tag" "$f"; then sudo cp "$f" "$BAKDIR/$(basename "$f")" # 在首个 server_name 行后插入(server 块内、顶层指令位置合法)