feat: Introduce ENABLE_AMAVIS env (#1866)

* Introduce ENABLE_AMAVIS env

* missing 'fi' added

* documentation added

* add condition for amavis fix function

* Fix spelling

Co-authored-by: William Desportes <williamdes@wdes.fr>

* Fix spelling

Co-authored-by: William Desportes <williamdes@wdes.fr>

Co-authored-by: William Desportes <williamdes@wdes.fr>
Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
This commit is contained in:
Casper 2021-03-28 15:37:48 +02:00 committed by GitHub
parent 666de3e2ec
commit dd0b399f33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 10 deletions

View file

@ -27,6 +27,13 @@ Here you can adjust the [log-level for Supervisor](http://supervisord.org/loggin
The log-level will show everything in its class and above. The log-level will show everything in its class and above.
##### ENABLE_AMAVIS
Amavis content filter (used for ClamAV & SpamAssassin)
- 0 => Amavis is disabled
- **1** => Amavis is enabled
##### ENABLE_CLAMAV ##### ENABLE_CLAMAV
- **0** => Clamav is disabled - **0** => Clamav is disabled

View file

@ -64,6 +64,11 @@ ENABLE_SRS=0
ENABLE_POP3= ENABLE_POP3=
ENABLE_CLAMAV=0 ENABLE_CLAMAV=0
# Amavis content filter (used for ClamAV & SpamAssassin)
# 0 => Disabled
# 1 => Enabled
ENABLE_AMAVIS=1
# If you enable Fail2Ban, don't forget to add the following lines to your `docker-compose.yml`: # If you enable Fail2Ban, don't forget to add the following lines to your `docker-compose.yml`:
# cap_add: # cap_add:
# - NET_ADMIN # - NET_ADMIN

View file

@ -20,6 +20,7 @@ VARS[DEFAULT_RELAY_HOST]="${DEFAULT_RELAY_HOST:=}"
VARS[DMS_DEBUG]="${DMS_DEBUG:=0}" VARS[DMS_DEBUG]="${DMS_DEBUG:=0}"
VARS[DOVECOT_MAILBOX_FORMAT]="${DOVECOT_MAILBOX_FORMAT:=maildir}" VARS[DOVECOT_MAILBOX_FORMAT]="${DOVECOT_MAILBOX_FORMAT:=maildir}"
VARS[DOVECOT_TLS]="${DOVECOT_TLS:=no}" VARS[DOVECOT_TLS]="${DOVECOT_TLS:=no}"
VARS[ENABLE_AMAVIS]="${ENABLE_AMAVIS:=1}"
VARS[ENABLE_CLAMAV]="${ENABLE_CLAMAV:=0}" VARS[ENABLE_CLAMAV]="${ENABLE_CLAMAV:=0}"
VARS[ENABLE_FAIL2BAN]="${ENABLE_FAIL2BAN:=0}" VARS[ENABLE_FAIL2BAN]="${ENABLE_FAIL2BAN:=0}"
VARS[ENABLE_FETCHMAIL]="${ENABLE_FETCHMAIL:=0}" VARS[ENABLE_FETCHMAIL]="${ENABLE_FETCHMAIL:=0}"
@ -149,7 +150,7 @@ function register_functions
# ? >> Fixes # ? >> Fixes
_register_fix_function '_fix_var_mail_permissions' _register_fix_function '_fix_var_mail_permissions'
_register_fix_function '_fix_var_amavis_permissions' [[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_fix_function '_fix_var_amavis_permissions'
[[ ${ENABLE_CLAMAV} -eq 0 ]] && _register_fix_function '_fix_cleanup_clamav' [[ ${ENABLE_CLAMAV} -eq 0 ]] && _register_fix_function '_fix_cleanup_clamav'
[[ ${ENABLE_SPAMASSASSIN} -eq 0 ]] && _register_fix_function '_fix_cleanup_spamassassin' [[ ${ENABLE_SPAMASSASSIN} -eq 0 ]] && _register_fix_function '_fix_cleanup_spamassassin'
@ -180,8 +181,7 @@ function register_functions
[[ ${ENABLE_FETCHMAIL} -eq 1 ]] && _register_start_daemon '_start_daemons_fetchmail' [[ ${ENABLE_FETCHMAIL} -eq 1 ]] && _register_start_daemon '_start_daemons_fetchmail'
[[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemons_clamav' [[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemons_clamav'
[[ ${ENABLE_LDAP} -eq 0 ]] && _register_start_daemon '_start_changedetector' [[ ${ENABLE_LDAP} -eq 0 ]] && _register_start_daemon '_start_changedetector'
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemons_amavis'
_register_start_daemon '_start_daemons_amavis'
} }
function _register_start_daemon function _register_start_daemon

View file

@ -128,10 +128,16 @@ function _setup_mailname
function _setup_amavis function _setup_amavis
{ {
if [[ ${ENABLE_AMAVIS} -eq 1 ]]
then
_notify 'task' 'Setting up Amavis' _notify 'task' 'Setting up Amavis'
sed -i \ sed -i \
"s|^#\$myhostname = \"mail.example.com\";|\$myhostname = \"${HOSTNAME}\";|" \ "s|^#\$myhostname = \"mail.example.com\";|\$myhostname = \"${HOSTNAME}\";|" \
/etc/amavis/conf.d/05-node_id /etc/amavis/conf.d/05-node_id
else
_notify 'task' 'Remove Amavis from postfix configuration'
sed -i 's|content_filter =.*|content_filter =|' /etc/postfix/main.cf
fi
} }
function _setup_dmarc_hostname function _setup_dmarc_hostname
@ -1475,11 +1481,15 @@ function _setup_security_stack
# fix cron.daily for spamassassin # fix cron.daily for spamassassin
sed -i -e 's|invoke-rc.d spamassassin reload|/etc/init\.d/spamassassin reload|g' /etc/cron.daily/spamassassin sed -i -e 's|invoke-rc.d spamassassin reload|/etc/init\.d/spamassassin reload|g' /etc/cron.daily/spamassassin
# copy user provided configuration files if provided # Amavis
if [[ ${ENABLE_AMAVIS} -eq 1 ]]
then
_notify 'inf' 'Amavis enabled'
if [[ -f /tmp/docker-mailserver/amavis.cf ]] if [[ -f /tmp/docker-mailserver/amavis.cf ]]
then then
cp /tmp/docker-mailserver/amavis.cf /etc/amavis/conf.d/50-user cp /tmp/docker-mailserver/amavis.cf /etc/amavis/conf.d/50-user
fi fi
fi
} }
function _setup_logrotate function _setup_logrotate