entrypoint.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. MAIL_HOSTNAME="${MAIL_HOSTNAME:-ali.ss5.xyz}"
  4. MAIL_ORIGIN_DOMAIN="${MAIL_ORIGIN_DOMAIN:-${MAIL_HOSTNAME#*.}}"
  5. POSTFIX_LOG_FILE="${POSTFIX_LOG_FILE:-/dev/stdout}"
  6. if [[ "${POSTFIX_LOG_FILE}" != "/dev/stdout" ]]; then
  7. mkdir -p "$(dirname "${POSTFIX_LOG_FILE}")"
  8. touch "${POSTFIX_LOG_FILE}"
  9. chmod 666 "${POSTFIX_LOG_FILE}"
  10. tail -n 0 -F "${POSTFIX_LOG_FILE}" &
  11. fi
  12. postconf -e "myhostname = ${MAIL_HOSTNAME}"
  13. postconf -e "myorigin = ${MAIL_ORIGIN_DOMAIN}"
  14. postconf -e "mydestination ="
  15. postconf -e "inet_interfaces = all"
  16. postconf -e "inet_protocols = ipv4"
  17. postconf -e "mynetworks = 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16"
  18. postconf -e "smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination"
  19. postconf -e "smtp_tls_security_level = may"
  20. postconf -e "smtp_tls_loglevel = 1"
  21. postconf -e "smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt"
  22. postconf -e "smtp_helo_name = ${MAIL_HOSTNAME}"
  23. postconf -e "disable_vrfy_command = yes"
  24. postconf -e "maximal_queue_lifetime = 2d"
  25. postconf -e "bounce_queue_lifetime = 2d"
  26. postconf -e "maillog_file = ${POSTFIX_LOG_FILE}"
  27. newaliases || true
  28. exec postfix start-fg