docker-entrypoint.sh 2.1 KB

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