Menu
Public repository / 7c2481f3029b7b2f8b01818af3d8e5fa55a3ea0b
AkurAI-Platform / scripts/check-live.sh
Latest change e9d23626cc868090f731ec64cfaad00efcb232d2 - Merge AKURAI-PLATFORM-38 fix-forward by Ólafur Búi Ólafsson
#!/usr/bin/env bash
# AkurAI-Platform — production smoke check
# Run against the deployed public surface; all requests use HTTPS.
# Exits 0 when every check passes; exits non-zero on the first failure.
set -euo pipefail
DOMAIN="${AKURAI_PLATFORM_DOMAIN:-platform.olibuijr.com}"
BASE="https://${DOMAIN}"
TIMEOUT=10
FAIL=0
fail() { echo "FAIL [$*]" >&2; FAIL=1; }
pass() { echo " ok $*"; }
skip() { echo " skip $*"; }
# -- helpers --------------------------------------------------
check_url() {
local label="$1" url="$2" expected="${3:-200}" method="${4:-GET}" body="${5:-}"
local code
if [[ -n "$body" ]]; then
code="$(curl -sS -o /dev/null -w '%{http_code}' --max-time "$TIMEOUT" -L -X "$method" -H 'Content-Type: application/json' --data "$body" "$url" 2>/dev/null || true)"
else
code="$(curl -sS -o /dev/null -w '%{http_code}' --max-time "$TIMEOUT" -L -X "$method" "$url" 2>/dev/null || true)"
fi
if [[ "$code" == "$expected" ]]; then
pass "$label ($code)"
else
fail "$label — wanted $expected, got ${code:-000} ($url)"
fi
}
check_content() {
local label="$1" url="$2" pattern="$3" cookie="${4:-}"
local body
if [[ -n "$cookie" ]]; then
body="$(curl -fsS --max-time "$TIMEOUT" -L -H "Cookie: $cookie" "$url" 2>/dev/null || true)"
else
body="$(curl -fsS --max-time "$TIMEOUT" -L "$url" 2>/dev/null || true)"
fi
if echo "$body" | grep -qFe "$pattern"; then
pass "$label"
else
fail "$label — missing '$pattern' ($url)"
fi
}
check_header() {
local label="$1" url="$2" header="$3" expected="$4" value
value="$(curl -fsSI --max-time "$TIMEOUT" -L "$url" 2>/dev/null | sed -n "/^${header}:/I{s/^[^:]*:[[:space:]]*//;s/[[:space:]]*$//;p;q}" || true)"
if [[ "${value,,}" == "$expected" ]]; then
pass "$label ($header: $value)"
else
fail "$label — wanted $header: $expected, got '${value:-missing}' ($url)"
fi
}
check_json_field() {
local label="$1" url="$2" field="$3" expected="$4"
local val
val="$(curl -fsS --max-time "$TIMEOUT" -L "$url" 2>/dev/null | python3 -c "
import json, sys
d = json.load(sys.stdin)
parts = '$field'.split('.')
for p in parts: d = d[p]
print(json.dumps(d))
" 2>/dev/null || echo "PARSE_ERROR")"
if [[ "$val" == "$expected" ]]; then
pass "$label ($val)"
else
fail "$label — wanted $expected, got $val ($url)"
fi
}
echo "=== AkurAI-Platform smoke ($BASE) ==="
echo ""
# --- DNS -----------------------------------------------------
echo "-- DNS --"
IP=""
if command -v dig >/dev/null 2>&1; then
IP="$(dig +short "$DOMAIN" A 2>/dev/null | grep -Em1 '^[0-9.]+$' || true)"
fi
if [[ -z "$IP" ]] && command -v getent >/dev/null 2>&1; then
IP="$(getent ahostsv4 "$DOMAIN" 2>/dev/null | awk '{print $1; exit}' || true)"
fi
if [[ -z "$IP" ]] && command -v python3 >/dev/null 2>&1; then
IP="$(python3 -c "import socket,sys; print(socket.gethostbyname(sys.argv[1]))" "$DOMAIN" 2>/dev/null || true)"
fi
if [[ -n "$IP" ]]; then
pass "DNS resolves ($IP)"
else
skip "DNS resolution ($DOMAIN — no resolver tool available)"
fi
# --- public app links ----------------------------------------
echo ""
echo "-- public app links --"
check_url "AkurAI Mail" "https://mail.olibuijr.com"
check_url "AkurAI IDP" "https://auth.olibuijr.com"
check_url "AkurAI VPN" "https://akurai-vpn.olibuijr.com"
check_url "AkurAI PassVault" "https://akurai-passvault.olibuijr.com"
check_url "AkurAI Drive" "https://akurai-drive.olibuijr.com"
check_url "AkurAI Notes" "https://akurai-notes.olibuijr.com"
check_url "AkurAI Tasks" "https://akurai-tasks.olibuijr.com"
check_url "AkurAI Router (health)" "https://akurai-router.olibuijr.com/health"
check_url "AkurAI Monitor" "https://monitor.olibuijr.com"
check_url "AkurAI Build" "https://akurai-build.olibuijr.com"
check_url "AkurAI Framework" "https://akurai-framework.olibuijr.com"
check_url "AkurAI Platform (self)" "$BASE"
# --- source/build repository links ---------------------------
echo ""
echo "-- source/build repository links --"
check_url "Build: AkurAI-Mail" "https://akurai-build.olibuijr.com/repos/AkurAI-Mail"
check_url "Build: AkurAI-MailAPI" "https://akurai-build.olibuijr.com/repos/AkurAI-MailAPI"
check_url "Build: AkurAI-IDP" "https://akurai-build.olibuijr.com/repos/AkurAI-IDP"
check_url "Build: AkurAI-VPN" "https://akurai-build.olibuijr.com/repos/AkurAI-VPN"
check_url "Build: AkurAI-PassVault" "https://akurai-build.olibuijr.com/repos/AkurAI-PassVault"
check_url "Build: AkurAI-Drive" "https://akurai-build.olibuijr.com/repos/AkurAI-Drive"
check_url "Build: AkurAI-Notes" "https://akurai-build.olibuijr.com/repos/AkurAI-Notes"
check_url "Build: AkurAI-CRM" "https://akurai-build.olibuijr.com/repos/AkurAI-CRM"
check_url "Build: AkurAI-Tasks" "https://akurai-build.olibuijr.com/repos/akurai-tasks"
check_url "Build: AkurAI-Router" "https://akurai-build.olibuijr.com/repos/AkurAI-Router"
check_url "Build: AkurAI-Monitor" "https://akurai-build.olibuijr.com/repos/AkurAI-Monitor"
check_url "Build: AkurAI-DNS" "https://akurai-build.olibuijr.com/repos/AkurAI-DNS"
check_url "Build: AkurAI-Build" "https://akurai-build.olibuijr.com/repos/AkurAI-Build"
check_url "Build: AkurAI-Framework" "https://akurai-build.olibuijr.com/repos/AkurAI-Framework"
check_url "Build: AkurAI-Platform" "https://akurai-build.olibuijr.com/repos/AkurAI-Platform"
# --- theme assets --------------------------------------------
echo ""
echo "-- theme assets --"
check_content "themes.css" "$BASE/themes.css" '--bg'
check_content "themes.json" "$BASE/themes.json" '['
# --- health endpoints ----------------------------------------
echo ""
echo "-- health endpoints --"
check_json_field "Platform /api/health" "$BASE/api/health" 'status' '"ok"'
check_json_field "Payments /api/health" "$BASE/api/payments/health" 'ok' 'true'
# --- edge security headers -----------------------------------
echo ""
echo "-- edge security headers --"
check_header "Framework route" "$BASE/" "x-content-type-options" "nosniff"
check_header "Payment route" "$BASE/api/payments/health" "x-content-type-options" "nosniff"
# --- control-plane API edge ---------------------------------
echo ""
echo "-- control-plane API edge --"
check_url "Organization API requires identity" "$BASE/api/organizations" 401
check_url "Contact API validates input" "$BASE/api/contact" 400 POST '{}'
# --- locale parity -------------------------------------------
echo ""
echo "-- locale parity --"
check_content "English locale active" "$BASE/" 'Pricing' 'akurai-lang=en'
check_content "Icelandic locale active" "$BASE/" 'Verðskrá' 'akurai-lang=is'
# --- checkout degraded state ---------------------------------
echo ""
echo "-- checkout degraded state --"
check_content "checkout disabled (en)" "$BASE/" 'myPOS'
check_content "checkout disabled (is)" "$BASE/" 'myPOS' 'akurai-lang=is'
# --- direct edge route ---------------------------------------
echo ""
echo "-- direct edge --"
if [[ -n "${AKURAI_PLATFORM_IP:-}" ]]; then
check_url "direct edge" "https://${AKURAI_PLATFORM_IP}/" 200
else
echo " skip direct edge (AKURAI_PLATFORM_IP not set)"
fi
# --- summary -------------------------------------------------
echo ""
if [[ "$FAIL" -eq 0 ]]; then
echo "=== all checks passed ==="
exit 0
else
echo "=== $FAIL check(s) failed ===" >&2
exit 1
fi