#!/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}"