1
0
mirror of git://f0xx.org/ac/ac-deploy synced 2026-07-29 03:38:07 +03:00
Files
ac-deploy/sim/cluster0/scripts/verify-mail-lab.sh
Anton Afanasyeu 62ba6aa615 cluster0: compose overlays lab-seed shortener; fix workspace git safe.dir
Re-copy ShortLinksRepository from NFS seed after ac-ms-* overlays;
deploy-ac-workspace allows all safe.directory; verify-mail-lab logs short URL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 19:08:42 +02:00

44 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Lab SMTP smoke — requires secrets.lab.env SMTP_* or local relay on cast01.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck source=/dev/null
. "$ROOT/scripts/lib/common.sh"
load_cluster_env
load_secrets_lab
TO="${1:-}"
[ -n "$TO" ] || die "usage: verify-mail-lab.sh recipient@example.com"
COMPOSED="${COMPOSE_BACKEND:-/var/www/ac/composed/backend}"
[ -f "${COMPOSED}/config/config.php" ] || die "missing composed backend — run compose-lab-backend.sh"
export MAIL_TEST_TO="$TO"
PHP="${PHP_BIN:-php83}"
command -v "$PHP" >/dev/null 2>&1 || PHP=php
_origin="${LAB_PUBLIC_ORIGIN:-https://acl0.f0xx.org}"
_token="lab-smoke-$(date +%s)"
_long="${_origin%/}/app/androidcast_project/issues/verify-email?token=${_token}"
export MAIL_TEST_LONG="$_long"
_out="$("$PHP" -r '
require "'"${COMPOSED}"'/src/bootstrap.php";
$to = getenv("MAIL_TEST_TO") ?: "";
$long = getenv("MAIL_TEST_LONG") ?: "";
$short = $long;
if (is_callable(["ShortLinksRepository", "shortenForOutboundMail"])) {
$pack = ShortLinksRepository::shortenForOutboundMail($long, 86400);
$short = (string) ($pack["short_url"] ?? $long);
}
$ok = AuthMailer::sendVerifyEmail($to, $long);
echo ($ok ? "mail_ok" : "mail_fail") . " short=" . $short;
' 2>&1)" || _out="mail_fail"
log "$_out to=$TO"
if echo "$_out" | grep -q mail_ok; then
log "hint: expect s.f0xx.org short link + inline QR via s.f0xx.org/api/v1/qr/…png (encodes …&src=qr)"
fi
case "$_out" in
mail_ok) exit 0 ;;
*) exit 1 ;;
esac