AkurAI Build
Menu

Public repository / 22202d1bde69be4ace8a299dffd91f8ff24378df

AkurAI-Mail / scripts/validate.sh

Latest change ce5f5ce299b8d0bd0440b215bf3ba322a862942a - OLI-134: canonical mail validate.sh; fix set -e pass++ abort by Ólafur Búi Ólafsson

#!/usr/bin/env bash
# scripts/validate.sh — Post-deploy validation for the AkurAI mail service
# (Rust akurai-mail-api + SvelteKit UI, deployed as one unit: akurai-mail-ui).
# Canonical copy lives in AkurAI-Mail; AkurAI-MailAPI carries a byte-identical copy
# (enforced by AkurAI-MailAPI/scripts/check-validate-sync.sh).
set -euo pipefail

: "${DOMAIN:=mail.olibuijr.com}"
: "${PORT:=3000}"
: "${APP_NAME:=akurai-mail-ui}"
RED='\033[0;31m'; GRN='\033[0;32m'; NC='\033[0m'
pass=0; fail=0
pass_() { printf "  ${GRN}PASS${NC} %s\n" "$*"; ((++pass)); }
fail_() { printf "  ${RED}FAIL${NC} %s\n" "$*"; ((++fail)); }

echo "=== Post-deploy validation: ${APP_NAME} ==="

systemctl is-active --quiet "${APP_NAME}.service" 2>/dev/null && pass_ "systemd active" || fail_ "systemd not active"

curl -fsS --max-time 5 "http://127.0.0.1:${PORT}/" > /dev/null 2>&1 && pass_ "loopback reachable" || fail_ "loopback unreachable"
curl -fsS --max-time 10 "https://${DOMAIN}/" > /dev/null 2>&1 && pass_ "public reachable" || fail_ "public unreachable"

curl -fsS --max-time 5 "http://127.0.0.1:${PORT}/login" 2>/dev/null | grep -qi 'login\|password\|sign' && pass_ "login page renders" || fail_ "login page not found"
curl -fsS --max-time 5 "https://${DOMAIN}/api/health" 2>/dev/null | python3 -c 'import sys,json; d=json.load(sys.stdin); assert d["app"] and d["version"] and d["status"]=="ok"' 2>/dev/null && pass_ "health contract {app,version,status}" || fail_ "health contract failed"
curl -fsS --max-time 5 "https://${DOMAIN}/api/auth/check" > /dev/null 2>&1 && pass_ "auth check endpoint" || fail_ "auth check endpoint failed"

echo "━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${GRN}Pass: $pass${NC}  ${RED}Fail: $fail${NC}"
[ "$fail" -eq 0 ] || exit 1