fix: fetch all SMTP config (host, user, password) from claude-ops
The rSwag Infisical project has stale SMTP values that can't be updated (admin identity not a project member). Fetch authoritative SMTP_HOST, SMTP_USER, and SMTP_PASSWORD from claude-ops /mail folder which overrides stale values from both .env and rSwag Infisical project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4d2d5d3132
commit
0b54b765df
|
|
@ -62,9 +62,8 @@ else
|
||||||
echo "[infisical] Starting with existing env vars"
|
echo "[infisical] Starting with existing env vars"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fetch SMTP password from claude-ops /mail if not already set
|
# Fetch SMTP config from claude-ops /mail (authoritative source for rSwag email)
|
||||||
if [ -z "$SMTP_PASSWORD" ]; then
|
SMTP_OVERRIDES=$(python3 -c "
|
||||||
SMTP_PWD=$(python3 -c "
|
|
||||||
import urllib.request, json, os, sys
|
import urllib.request, json, os, sys
|
||||||
base = os.environ.get('INFISICAL_URL', 'http://infisical:8080')
|
base = os.environ.get('INFISICAL_URL', 'http://infisical:8080')
|
||||||
try:
|
try:
|
||||||
|
|
@ -74,17 +73,18 @@ try:
|
||||||
req = urllib.request.Request(f'{base}/api/v3/secrets/raw?workspaceSlug=claude-ops&environment=prod&secretPath=/mail')
|
req = urllib.request.Request(f'{base}/api/v3/secrets/raw?workspaceSlug=claude-ops&environment=prod&secretPath=/mail')
|
||||||
req.add_header('Authorization', f'Bearer {token}')
|
req.add_header('Authorization', f'Bearer {token}')
|
||||||
secrets = json.loads(urllib.request.urlopen(req).read())
|
secrets = json.loads(urllib.request.urlopen(req).read())
|
||||||
|
mapping = {'RSWAG_SMTP_HOST': 'SMTP_HOST', 'RSWAG_SMTP_USER': 'SMTP_USER', 'RSWAG_SMTP_PASSWORD': 'SMTP_PASSWORD'}
|
||||||
for s in secrets.get('secrets',[]):
|
for s in secrets.get('secrets',[]):
|
||||||
if s['secretKey'] == 'RSWAG_SMTP_PASSWORD':
|
env_key = mapping.get(s['secretKey'])
|
||||||
print(s['secretValue'])
|
if env_key:
|
||||||
break
|
val = s['secretValue'].replace(\"'\", \"'\\\\'\")
|
||||||
|
print(f\"export {env_key}='{val}'\")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'[smtp] Could not fetch password: {e}', file=sys.stderr)
|
print(f'[smtp] Could not fetch from claude-ops: {e}', file=sys.stderr)
|
||||||
" 2>&1) || true
|
" 2>&1) || true
|
||||||
if [ -n "$SMTP_PWD" ] && echo "$SMTP_PWD" | grep -qv '^\['; then
|
if echo "$SMTP_OVERRIDES" | grep -q "^export "; then
|
||||||
export SMTP_PASSWORD="$SMTP_PWD"
|
eval "$SMTP_OVERRIDES"
|
||||||
echo "[infisical] Fetched SMTP password from claude-ops/mail"
|
echo "[infisical] Loaded SMTP config from claude-ops/mail"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue