docker-entrypoint.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Run hooks
  3. for file in /hooks/*; do
  4. if [ -x "${file}" ]; then
  5. echo "Running hook ${file}"
  6. "${file}"
  7. fi
  8. done
  9. python3 -u /bootstrap/main.py
  10. BOOTSTRAP_EXIT_CODE=$?
  11. if [ $BOOTSTRAP_EXIT_CODE -ne 0 ]; then
  12. echo "Bootstrap failed with exit code $BOOTSTRAP_EXIT_CODE. Not starting Postfix."
  13. exit $BOOTSTRAP_EXIT_CODE
  14. fi
  15. # Fix OpenSSL 3.X TLS1.0, 1.1 support (https://community.mailcow.email/d/4062-hi-all/20)
  16. if grep -qE '\!SSLv2|\!SSLv3|>=TLSv1(\.[0-1])?$' /opt/postfix/conf/main.cf /opt/postfix/conf/extra.cf; then
  17. sed -i '/\[openssl_init\]/a ssl_conf = ssl_configuration' /etc/ssl/openssl.cnf
  18. echo "[ssl_configuration]" >> /etc/ssl/openssl.cnf
  19. echo "system_default = tls_system_default" >> /etc/ssl/openssl.cnf
  20. echo "[tls_system_default]" >> /etc/ssl/openssl.cnf
  21. echo "MinProtocol = TLSv1" >> /etc/ssl/openssl.cnf
  22. echo "CipherString = DEFAULT@SECLEVEL=0" >> /etc/ssl/openssl.cnf
  23. fi
  24. # Start Postfix
  25. postconf -c /opt/postfix/conf > /dev/null
  26. if [[ $? != 0 ]]; then
  27. echo "Postfix configuration error, refusing to start."
  28. exit 1
  29. else
  30. echo "Bootstrap succeeded. Starting Postfix..."
  31. postfix -c /opt/postfix/conf start
  32. sleep 126144000
  33. fi