mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
setup: improve Amavis setup routine (#3079)
* improve Amavis setup routine see https://github.com/docker-mailserver/docker-mailserver/pull/3046#issuecomment-1423718811
This commit is contained in:
parent
f5d325bdc1
commit
40e10d755d
|
@ -85,9 +85,6 @@ virtual_mailbox_domains = /etc/postfix/vhost
|
||||||
virtual_mailbox_maps = texthash:/etc/postfix/vmailbox
|
virtual_mailbox_maps = texthash:/etc/postfix/vmailbox
|
||||||
virtual_alias_maps = texthash:/etc/postfix/virtual
|
virtual_alias_maps = texthash:/etc/postfix/virtual
|
||||||
|
|
||||||
# Additional option for filtering
|
|
||||||
content_filter = smtp-amavis:[127.0.0.1]:10024
|
|
||||||
|
|
||||||
# Milters used by DKIM
|
# Milters used by DKIM
|
||||||
milter_protocol = 6
|
milter_protocol = 6
|
||||||
milter_default_action = accept
|
milter_default_action = accept
|
||||||
|
|
|
@ -73,14 +73,14 @@ function _setup_amavis
|
||||||
if [[ ${ENABLE_AMAVIS} -eq 1 ]]
|
if [[ ${ENABLE_AMAVIS} -eq 1 ]]
|
||||||
then
|
then
|
||||||
_log 'debug' 'Setting up Amavis'
|
_log 'debug' 'Setting up Amavis'
|
||||||
|
|
||||||
cat /etc/dms/postfix/master.d/postfix-amavis.cf >>/etc/postfix/master.cf
|
cat /etc/dms/postfix/master.d/postfix-amavis.cf >>/etc/postfix/master.cf
|
||||||
|
postconf 'content_filter = smtp-amavis:[127.0.0.1]:10024'
|
||||||
|
|
||||||
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
|
else
|
||||||
_log 'debug' "Removing Amavis from Postfix's configuration"
|
|
||||||
sed -i 's|content_filter =.*|content_filter =|' /etc/postfix/main.cf
|
|
||||||
|
|
||||||
_log 'debug' 'Disabling Amavis cron job'
|
_log 'debug' 'Disabling Amavis cron job'
|
||||||
mv /etc/cron.d/amavisd-new /etc/cron.d/amavisd-new.disabled
|
mv /etc/cron.d/amavisd-new /etc/cron.d/amavisd-new.disabled
|
||||||
chmod 0 /etc/cron.d/amavisd-new.disabled
|
chmod 0 /etc/cron.d/amavisd-new.disabled
|
||||||
|
|
|
@ -2,23 +2,52 @@ load "${REPOSITORY_ROOT}/test/helper/common"
|
||||||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||||
|
|
||||||
BATS_TEST_NAME_PREFIX='[Amavis + SA] '
|
BATS_TEST_NAME_PREFIX='[Amavis + SA] '
|
||||||
CONTAINER_NAME='dms-test_amavis'
|
CONTAINER1_NAME='dms-test_amavis_enabled'
|
||||||
|
CONTAINER2_NAME='dms-test_amavis_disabled'
|
||||||
|
|
||||||
function setup_file() {
|
function setup_file() {
|
||||||
_init_with_defaults
|
export CONTAINER_NAME
|
||||||
|
|
||||||
|
CONTAINER_NAME=${CONTAINER1_NAME}
|
||||||
|
_init_with_defaults
|
||||||
local CUSTOM_SETUP_ARGUMENTS=(
|
local CUSTOM_SETUP_ARGUMENTS=(
|
||||||
--env ENABLE_AMAVIS=1
|
--env ENABLE_AMAVIS=1
|
||||||
--env AMAVIS_LOGLEVEL=2
|
--env AMAVIS_LOGLEVEL=2
|
||||||
--env ENABLE_SPAMASSASSIN=1
|
--env ENABLE_SPAMASSASSIN=1
|
||||||
)
|
)
|
||||||
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||||
|
|
||||||
|
CONTAINER_NAME=${CONTAINER2_NAME}
|
||||||
|
_init_with_defaults
|
||||||
|
local CUSTOM_SETUP_ARGUMENTS=(
|
||||||
|
--env ENABLE_AMAVIS=0
|
||||||
|
--env ENABLE_SPAMASSASSIN=0
|
||||||
|
)
|
||||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||||
}
|
}
|
||||||
|
|
||||||
function teardown_file() { _default_teardown ; }
|
function teardown_file() { _default_teardown ; }
|
||||||
|
|
||||||
@test 'SpamAssassin integration should be active' {
|
@test '(Amavis enabled) configuration should be correct' {
|
||||||
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||||
|
|
||||||
|
_run_in_container postconf -h content_filter
|
||||||
|
assert_success
|
||||||
|
assert_line 'smtp-amavis:[127.0.0.1]:10024'
|
||||||
|
_run_in_container grep 'smtp-amavis' /etc/postfix/master.cf
|
||||||
|
assert_success
|
||||||
|
_run_in_container grep -F '127.0.0.1:10025' /etc/postfix/master.cf
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
_run_in_container_bash '[[ -f /etc/cron.d/amavisd-new.disabled ]]'
|
||||||
|
assert_failure
|
||||||
|
_run_in_container_bash '[[ -f /etc/cron.d/amavisd-new ]]'
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test '(Amavis enabled) SA integration should be active' {
|
||||||
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||||
|
|
||||||
# give Amavis just a bit of time to print out its full debug log
|
# give Amavis just a bit of time to print out its full debug log
|
||||||
run _repeat_in_container_until_success_or_timeout 5 "${CONTAINER_NAME}" grep 'ANTI-SPAM-SA' /var/log/mail/mail.log
|
run _repeat_in_container_until_success_or_timeout 5 "${CONTAINER_NAME}" grep 'ANTI-SPAM-SA' /var/log/mail/mail.log
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -26,7 +55,9 @@ function teardown_file() { _default_teardown ; }
|
||||||
refute_output --partial 'NOT loaded'
|
refute_output --partial 'NOT loaded'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'SA ENV should update Amavis config' {
|
@test '(Amavis enabled) SA ENV should update Amavis config' {
|
||||||
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||||
|
|
||||||
local AMAVIS_DEFAULTS_FILE='/etc/amavis/conf.d/20-debian_defaults'
|
local AMAVIS_DEFAULTS_FILE='/etc/amavis/conf.d/20-debian_defaults'
|
||||||
_run_in_container grep '\$sa_tag_level_deflt' "${AMAVIS_DEFAULTS_FILE}"
|
_run_in_container grep '\$sa_tag_level_deflt' "${AMAVIS_DEFAULTS_FILE}"
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -44,3 +75,20 @@ function teardown_file() { _default_teardown ; }
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "= '***SPAM*** ';"
|
assert_output --partial "= '***SPAM*** ';"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test '(Amavis disabled) configuration should be correct' {
|
||||||
|
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||||
|
|
||||||
|
_run_in_container postconf -h content_filter
|
||||||
|
assert_success
|
||||||
|
refute_output --partial 'smtp-amavis:[127.0.0.1]:10024'
|
||||||
|
_run_in_container grep 'smtp-amavis' /etc/postfix/master.cf
|
||||||
|
assert_failure
|
||||||
|
_run_in_container grep -F '127.0.0.1:10025' /etc/postfix/master.cf
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
_run_in_container_bash '[[ -f /etc/cron.d/amavisd-new.disabled ]]'
|
||||||
|
assert_success
|
||||||
|
_run_in_container_bash '[[ -f /etc/cron.d/amavisd-new ]]'
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue