#!/bin/bash set -e rm -f /etc/caddy/sites/nomadro.com.caddy echo 'removed sites/nomadro.com.caddy' cp -a /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak.nomadro_next_$(date +%Y%m%d_%H%M%S) python3 <<'PY' from pathlib import Path import re p = Path("/etc/caddy/Caddyfile") text = p.read_text(encoding="utf-8") text2, n = re.subn( r"(nomadro\.com\s*\{[^}]*?reverse_proxy\s+)127\.0\.0\.1:4403", r"\g<1>127.0.0.1:4003", text, count=1, flags=re.S, ) if n != 1: raise SystemExit(f"patch failed n={n}") text2 = text2.replace( "# Audience router: zh → Next.js, en/bots → WordPress", "# Next.js only (WordPress / audience router not used)", 1, ) p.write_text(text2, encoding="utf-8") print("patched Caddyfile ok") PY head -20 /etc/caddy/Caddyfile caddy validate --config /etc/caddy/Caddyfile systemctl reload caddy || systemctl restart caddy sleep 1 systemctl is-active caddy systemctl enable --now nomadro.service systemctl restart nomadro.service sleep 2 systemctl is-active nomadro.service ss -lntp | grep ':4003' || true curl -sS -m 10 -o /dev/null -w 'local=%{http_code}\n' http://127.0.0.1:4003/ curl -sS -m 15 -o /dev/null -w 'public=%{http_code}\n' -L https://nomadro.com/ curl -sS -m 15 -o /dev/null -w 'www=%{http_code}\n' -L https://www.nomadro.com/ echo 'wp_left_as_is:' docker ps --format '{{.Names}} {{.Status}}' | grep -i wordpress || true systemctl is-active nomadro-router.service || echo 'router=inactive (ok)'