docker-entrypoint.sh 1.9 KB

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