docker-entrypoint.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. RSPAMD_V4=
  30. RSPAMD_V6=
  31. until [[ ! -z ${RSPAMD_V4} ]]; do
  32. RSPAMD_V4=$(dig a rspamd +short)
  33. RSPAMD_V6=$(dig aaaa rspamd +short)
  34. [[ ! -z ${RSPAMD_V4} ]] && break;
  35. echo "Waiting for Rspamd..."
  36. sleep 3
  37. done
  38. echo ${RSPAMD_V4}/32 > /etc/rspamd/custom/rspamd_trusted.map
  39. if [[ ! -z ${RSPAMD_V6} ]]; then
  40. echo ${RSPAMD_V6}/128 >> /etc/rspamd/custom/rspamd_trusted.map
  41. fi
  42. chown -R _rspamd:_rspamd /var/lib/rspamd \
  43. /etc/rspamd/local.d \
  44. /etc/rspamd/override.d \
  45. /etc/rspamd/rspamd.conf.local \
  46. /etc/rspamd/rspamd.conf.override \
  47. /etc/rspamd/plugins.d
  48. # Fix missing default global maps, if any
  49. # These exists in mailcow UI and should not be removed
  50. touch /etc/rspamd/custom/global_mime_from_blacklist.map \
  51. /etc/rspamd/custom/global_rcpt_blacklist.map \
  52. /etc/rspamd/custom/global_smtp_from_blacklist.map \
  53. /etc/rspamd/custom/global_mime_from_whitelist.map \
  54. /etc/rspamd/custom/global_rcpt_whitelist.map \
  55. /etc/rspamd/custom/global_smtp_from_whitelist.map \
  56. /etc/rspamd/custom/bad_languages.map \
  57. /etc/rspamd/custom/sa-rules \
  58. /etc/rspamd/custom/dovecot_trusted.map \
  59. /etc/rspamd/custom/rspamd_trusted.map \
  60. /etc/rspamd/custom/ip_wl.map \
  61. /etc/rspamd/custom/fishy_tlds.map \
  62. /etc/rspamd/custom/bad_words.map \
  63. /etc/rspamd/custom/bad_asn.map \
  64. /etc/rspamd/custom/bad_words_de.map
  65. # www-data (82) group needs to write to these files
  66. chown _rspamd:_rspamd /etc/rspamd/custom/
  67. chmod 0755 /etc/rspamd/custom/.
  68. chown -R 82:82 /etc/rspamd/custom/*
  69. chmod 644 -R /etc/rspamd/custom/*
  70. # Run hooks
  71. for file in /hooks/*; do
  72. if [ -x "${file}" ]; then
  73. echo "Running hook ${file}"
  74. "${file}"
  75. fi
  76. done
  77. exec "$@"