docker-entrypoint.sh 2.1 KB

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