docker-entrypoint.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. until nc phpfpm 9001 -z; do
  3. echo "Waiting for PHP on port 9001..."
  4. sleep 3
  5. done
  6. until nc phpfpm 9002 -z; do
  7. echo "Waiting for PHP on port 9002..."
  8. sleep 3
  9. done
  10. mkdir -p /etc/rspamd/plugins.d \
  11. /etc/rspamd/custom
  12. touch /etc/rspamd/rspamd.conf.local \
  13. /etc/rspamd/rspamd.conf.override
  14. chmod 755 /var/lib/rspamd
  15. [[ ! -f /etc/rspamd/override.d/worker-controller-password.inc ]] && echo '# Autogenerated by mailcow' > /etc/rspamd/override.d/worker-controller-password.inc
  16. DOVECOT_V4=
  17. DOVECOT_V6=
  18. until [[ ! -z ${DOVECOT_V4} ]]; do
  19. DOVECOT_V4=$(dig a dovecot +short)
  20. DOVECOT_V6=$(dig aaaa dovecot +short)
  21. [[ ! -z ${DOVECOT_V4} ]] && break;
  22. echo "Waiting for Dovecot"
  23. sleep 3
  24. done
  25. echo ${DOVECOT_V4}/32 > /etc/rspamd/custom/dovecot_trusted.map
  26. if [[ ! -z ${DOVECOT_V6} ]]; then
  27. echo ${DOVECOT_V6}/128 >> /etc/rspamd/custom/dovecot_trusted.map
  28. fi
  29. chown -R _rspamd:_rspamd /var/lib/rspamd \
  30. /etc/rspamd/local.d \
  31. /etc/rspamd/override.d \
  32. /etc/rspamd/rspamd.conf.local \
  33. /etc/rspamd/rspamd.conf.override \
  34. /etc/rspamd/plugins.d
  35. # Fix missing default global maps, if any
  36. # These exists in mailcow UI and should not be removed
  37. touch /etc/rspamd/custom/global_mime_from_blacklist.map \
  38. /etc/rspamd/custom/global_rcpt_blacklist.map \
  39. /etc/rspamd/custom/global_smtp_from_blacklist.map \
  40. /etc/rspamd/custom/global_mime_from_whitelist.map \
  41. /etc/rspamd/custom/global_rcpt_whitelist.map \
  42. /etc/rspamd/custom/global_smtp_from_whitelist.map \
  43. /etc/rspamd/custom/sa-rules \
  44. /etc/rspamd/custom/dovecot_trusted.map \
  45. /etc/rspamd/custom/ip_wl.map \
  46. /etc/rspamd/custom/fishy_tlds.map \
  47. /etc/rspamd/custom/bad_words.map \
  48. /etc/rspamd/custom/bad_asn.map \
  49. /etc/rspamd/custom/bad_words_de.map
  50. # www-data (82) group needs to write to these files
  51. chown _rspamd:_rspamd /etc/rspamd/custom/
  52. chmod 0755 /etc/rspamd/custom/.
  53. chown -R 82:82 /etc/rspamd/custom/*
  54. chmod 644 -R /etc/rspamd/custom/*
  55. # Run hooks
  56. for file in /hooks/*; do
  57. if [ -x "${file}" ]; then
  58. echo "Running hook ${file}"
  59. "${file}"
  60. fi
  61. done
  62. exec "$@"