mas_modes.mailer.Mailer is the only outbound path (own SQLite + lock), shared by the ticket service and both EmailMode roles. Over the cap mail is held and reported (send-cap-reached, held); held mail is purged after email-held-duration-max (7d) and not stored beyond emails-held-storage-max (100MB). The ticket service's legacy outbox is imported once so the live count carries over (checked on a copy of the live DB: 4 sent). Entrypoint passes the cap and both limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 5787@bnt-lap001 Assistant-Session: 5db26b82-138b-40cc-9856-4d5eb0f752fd
63 lines
2.8 KiB
Bash
63 lines
2.8 KiB
Bash
#!/bin/sh
|
|
# mx : Postfix -> pipe -> mas-gateway -> capture (JSONL evidence) -> ticket service
|
|
# statute : static /.well-known/mas only (the only thing exposed over HTTPS)
|
|
set -e
|
|
DOMAIN="${MAS_DOMAIN:-mas.coulomb.social}"
|
|
STATUTE_DIR="/app/examples/statute/$DOMAIN"
|
|
|
|
if [ "$1" = "statute" ]; then
|
|
exec python3 /app/examples/statute/serve.py "$STATUTE_DIR" --host 0.0.0.0 --port 8080
|
|
fi
|
|
|
|
cat > /usr/local/bin/mas-gateway <<SH
|
|
#!/bin/sh
|
|
exec env PYTHONPATH=/app python3 -m mas_gateway.main "\$@"
|
|
SH
|
|
chmod +x /usr/local/bin/mas-gateway
|
|
|
|
# The MAS setup (relay control, no rewriting, mas pipe, outbound relay, sender
|
|
# authentication) is the integration profile; see integrations/postfix/.
|
|
# Port 25 out is blocked on railiance01, so replies go through an
|
|
# authenticated submission relay, and only when its credentials are mounted.
|
|
RELAY_ARGS=""
|
|
if [ -n "$MAS_RELAY" ] && [ -s /etc/mas-relay/username ]; then
|
|
RELAY_ARGS="--relay $MAS_RELAY --relay-credentials /etc/mas-relay"
|
|
fi
|
|
/app/integrations/postfix/install.sh --domain "$DOMAIN" \
|
|
--statute "$STATUTE_DIR/.well-known/mas" --app-url http://127.0.0.1:8024/mas-events --auth \
|
|
$RELAY_ARGS
|
|
|
|
# Deployment specifics.
|
|
postconf -e \
|
|
"maillog_file=/dev/stdout" "message_size_limit=10240000" \
|
|
"smtpd_banner=\$myhostname ESMTP MAS live test" \
|
|
"smtpd_tls_security_level=may" \
|
|
"smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem" \
|
|
"smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key" \
|
|
"inet_protocols=ipv4" "compatibility_level=3.6"
|
|
# start-fg does not populate the chroot (no resolv.conf), so DNS fails inside
|
|
# it: client rDNS shows "unknown" and a relayhost would not resolve. The
|
|
# container already isolates Postfix, so run the daemons unchrooted.
|
|
postconf -F '*/*/chroot = n'
|
|
|
|
# The ticket service sends replies only with a relay, capped at MAS_MAX_SENT in
|
|
# total; over the cap they are held, purged after 7d, at most 100MB (MAS-WP-0012).
|
|
SMTP_ARG=""
|
|
if [ -n "$MAS_RELAY" ] && [ -s /etc/mas-relay/username ]; then
|
|
SMTP_ARG="--smtp 127.0.0.1:25 --max-sent ${MAS_MAX_SENT:-300} --require-dmarc-pass \
|
|
--email-held-duration-max ${MAS_EMAIL_HELD_DURATION_MAX:-7d} \
|
|
--emails-held-storage-max ${MAS_EMAILS_HELD_STORAGE_MAX:-100MB}"
|
|
fi
|
|
|
|
# Milters in the foreground: daemonized, OpenDKIM died on its first
|
|
# connection in this container.
|
|
opendkim -f -x /etc/opendkim.conf &
|
|
opendmarc -f -c /etc/opendmarc.conf &
|
|
|
|
mkdir -p /var/lib/mas && chown mas /var/lib/mas
|
|
# Replies are only recorded in the outbox unless a relay is configured above.
|
|
su -s /bin/sh mas -c "python3 /app/examples/ticket_service/ticket_service.py \
|
|
--db /var/lib/mas/tickets.sqlite3 --listen 127.0.0.1:8025 $SMTP_ARG" &
|
|
su -s /bin/sh mas -c "python3 /app/capture.py http://127.0.0.1:8025/mas-events \
|
|
/var/lib/mas/events.jsonl 127.0.0.1" &
|
|
exec postfix start-fg
|