Files
landwelle/scripts/verify-api-subdomain.sh
T
Landwelle Server 672c6c9606
Landwelle CI / Linux x64 container build and smoke test (push) Failing after 37s
Landwelle CI / JavaScript and deployment-script checks (push) Successful in 39s
Landwelle GitHub source ZIP / source-zip (push) Successful in 43s
Landwelle CI / Linux x64 production build (push) Successful in 1m4s
Landwelle CI / Go tests and vet (push) Successful in 2m36s
sync: Landwelle v1.5.82 source and media gallery favorites
Synchronize validated production source; preserve admin highlights, seasons, cron fixes and media favorites. Remove obsolete Firebase, IT-app and Niedersachsen Hub regression tests, keeping current feature tests.
2026-12-03 02:30:15 +01:00

81 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
LOCAL_BASE="${LANDWELLE_LOCAL_API_BASE:-http://127.0.0.1:2200}"
PUBLIC_BASE="${LANDWELLE_PUBLIC_API_BASE:-https://api.landwelle.de}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
check_endpoint() {
local label="$1"
local url="$2"
local expected_content_type="$3"
local headers="$TMP_DIR/${label}.headers"
local body="$TMP_DIR/${label}.body"
local status
status="$(curl -sS --connect-timeout 5 --max-time 20 -D "$headers" -o "$body" -w '%{http_code}' "$url" || true)"
printf '%-28s %s HTTP %s\n' "$label" "$url" "$status"
if [[ "$status" != "200" ]]; then
echo " FEHLER: Erwartet wurde HTTP 200."
if [[ -s "$body" ]]; then
echo " Antwort: $(tr '\n' ' ' < "$body" | head -c 240)"
echo
fi
return 1
fi
if ! grep -qi "content-type:.*${expected_content_type}" "$headers"; then
echo " FEHLER: Unerwarteter Content-Type."
sed -n '1,20p' "$headers" | sed 's/^/ /'
return 1
fi
echo " OK"
}
local_ok=0
public_ok=0
if check_endpoint "lokale Web-API" "$LOCAL_BASE/api/v1/now" "application/json"; then
local_ok=1
fi
if check_endpoint "öffentliche Web-API" "$PUBLIC_BASE/api/v1/now" "application/json"; then
public_ok=1
fi
check_endpoint "öffentliche Web-API-Kontrolle" "${PUBLIC_BASE}/api/v1/now" "application/json" || true
check_endpoint "öffentlicher Healthcheck" "$PUBLIC_BASE/health" "application/json" || true
if [[ "$local_ok" -eq 1 && "$public_ok" -eq 0 ]]; then
cat <<'MSG'
DIAGNOSE:
Die Go-API läuft lokal, aber die API-Subdomain reicht /api/v1 nicht weiter.
In KeyHelp bei api.landwelle.de das vollständige Fragment
„deploy/keyhelp-api-subdomain-https.conf“ in „Anweisungen für HTTPS“ eintragen,
speichern und die Webserver-Konfiguration neu laden lassen.
MSG
exit 2
fi
if [[ "$local_ok" -ne 1 ]]; then
cat <<'MSG'
DIAGNOSE:
Die API antwortet bereits lokal nicht korrekt. Portalstatus prüfen:
systemctl status landwelle-radio --no-pager
curl -i http://127.0.0.1:2200/api/v1/now
MSG
exit 3
fi
if [[ "$public_ok" -ne 1 ]]; then
exit 4
fi
echo
echo "Landwelle Web-API ist korrekt erreichbar."