mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-07-29 08:59:30 +03:00
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>
25 lines
988 B
Bash
Executable File
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}"
|