From a6b3c450f8ab464546daad7a58a6d0cc07e8eafd Mon Sep 17 00:00:00 2001 From: Homelab Cursor Date: Sun, 28 Jun 2026 19:22:49 +0200 Subject: [PATCH] fix wp-mirror-sync: explicit HTTP 200/301 health check --- arakava-news/scripts/wp-mirror-sync.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arakava-news/scripts/wp-mirror-sync.sh b/arakava-news/scripts/wp-mirror-sync.sh index a6ed62922..8c7e1027b 100755 --- a/arakava-news/scripts/wp-mirror-sync.sh +++ b/arakava-news/scripts/wp-mirror-sync.sh @@ -20,6 +20,13 @@ log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG" } +ct101_http_ok() { + local code + code="$(ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \ + "pct exec ${HETZNER_CT} -- curl -sS -o /dev/null -w '%{http_code}' --max-time 15 http://127.0.0.1/" 2>/dev/null || echo 000)" + [[ "$code" == "200" || "$code" == "301" ]] +} + tar_sync_files() { rm -rf "${STAGING}/wpfiles" mkdir -p "${STAGING}/wpfiles" @@ -50,9 +57,8 @@ fi mkdir -p "$STAGING" "$(dirname "$LOG")" log "Checking CT101 health..." -if ! ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \ - "pct exec ${HETZNER_CT} -- curl -sf -o /dev/null --max-time 15 http://127.0.0.1/"; then - log "ABORT: CT101 does not respond on http://127.0.0.1/" +if ! ct101_http_ok; then + log "ABORT: CT101 does not respond on http://127.0.0.1/ (expected HTTP 200/301)" exit 1 fi @@ -109,8 +115,7 @@ LAST="$(pct exec "$MIRROR_CT" -- docker exec wordpress-mysql mysql -u"$MYSQL_USE "SELECT MAX(post_date) FROM wp_posts WHERE post_type='post';" "$MYSQL_DB" 2>/dev/null)" log "Mirror verified: ${POSTS} published posts, latest ${LAST}" -if ! ssh -o BatchMode=yes -o ConnectTimeout=15 "$HETZNER_HOST" \ - "pct exec ${HETZNER_CT} -- curl -sf -o /dev/null --max-time 15 http://127.0.0.1/"; then +if ! ct101_http_ok; then log "WARN: CT101 health check failed AFTER sync — investigate immediately" exit 1 fi