1
0
mirror of git://f0xx.org/ac/ac-deploy synced 2026-07-29 08:38:36 +03:00
Files
ac-deploy/sim/cluster0/scripts/ensure-auth-email-bearer.sh
Anton Afanasyeu aa55e03fbd cluster0: auth-email bearer + shorten verify URLs in outbound mail
ShortLinksRepository::shortenForOutbound; ensure-auth-email-bearer.sh;
verify-mail-lab sends shortened s.f0xx.org link in verify email body.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 18:37:24 +02:00

25 lines
988 B
Bash
Executable File

#!/bin/sh
# Mint auth-email bearer for outbound mail short links; store id in secrets + config.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck source=/dev/null
. "$ROOT/scripts/lib/common.sh"
load_cluster_env
COMPOSED="${COMPOSE_BACKEND:-/var/www/ac/composed/backend}"
SCRIPT="${COMPOSED}/scripts/ensure_auth_email_bearer.php"
[ -f "$SCRIPT" ] || SCRIPT="${ROOT}/lab-seeds/backend/scripts/ensure_auth_email_bearer.php"
[ -f "$SCRIPT" ] || die "ensure_auth_email_bearer.php missing"
BEARER_ID="$(php83 "$SCRIPT" 2>/dev/null | tail -1)"
[ -n "$BEARER_ID" ] && [ "$BEARER_ID" -gt 0 ] 2>/dev/null || die "could not mint auth-email bearer"
SECRETS="${CAST_CLUSTER_ROOT}/secrets.lab.env"
if [ -f "$SECRETS" ]; then
grep -v '^URL_SHORTENER_AUTH_BEARER_ID=' "$SECRETS" > /tmp/secrets.new || true
echo "URL_SHORTENER_AUTH_BEARER_ID=${BEARER_ID}" >> /tmp/secrets.new
mv /tmp/secrets.new "$SECRETS"
chmod 600 "$SECRETS"
fi
log "ensure-auth-email-bearer_ok id=${BEARER_ID}"