#!/usr/bin/env bash
set -e
install -m 644 /tmp/account.allgifted.com.conf /etc/apache2/sites-available/account.allgifted.com.conf
a2ensite account.allgifted.com.conf
apache2ctl configtest 2>&1
systemctl reload apache2
echo "=== Smoke tests via Host: header (HTTP) ==="
curl -s -o /dev/null -w "GET /        Host: account.allgifted.com → %{http_code}  loc=%{redirect_url}  size=%{size_download}\n" -H "Host: account.allgifted.com" http://127.0.0.1/
curl -s -o /dev/null -w "GET /login    Host: account.allgifted.com → %{http_code}  size=%{size_download}\n" -H "Host: account.allgifted.com" http://127.0.0.1/login
echo ""
echo "=== Page sanity (first 30 lines of /login) ==="
curl -s -H "Host: account.allgifted.com" http://127.0.0.1/login | head -30
echo ""
echo "=== Math + vocab still alive ==="
curl -s -o /dev/null -w "math    %{http_code}\n" https://math.allgifted.com/
curl -s -o /dev/null -w "vocab   %{http_code}\n" https://vocab.allgifted.com/
curl -s -o /dev/null -w "vocabapi/api/voices %{http_code}\n" https://vocabapi.allgifted.com/api/voices
