From 60afbe1d1637cb617beaf6317b4d18de7ea60c9b Mon Sep 17 00:00:00 2001 From: Daniel Panteleit Date: Sun, 23 Jul 2017 21:31:41 +0200 Subject: [PATCH] Disable logrotate and cron job for updating clamav if clamav is disabled (fixes #660) (#667) --- Dockerfile | 3 +-- target/start-mailserver.sh | 9 +++++++++ test/tests.bats | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 67ae419a..0dd6dff1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,8 +66,7 @@ RUN apt-get update -q --fix-missing && \ update-locale && \ rm -f /etc/cron.weekly/fstrim -# Enables Clamav -RUN (echo "0 0,6,12,18 * * * /usr/bin/freshclam --quiet" ; crontab -l) | crontab - && \ +RUN echo "0 0,6,12,18 * * * /usr/bin/freshclam --quiet" > /etc/cron.d/freshclam && \ chmod 644 /etc/clamav/freshclam.conf && \ freshclam diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index c0d6ab87..3cca7897 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -129,6 +129,9 @@ function register_functions() { _register_fix_function "_fix_var_mail_permissions" _register_fix_function "_fix_var_amavis_permissions" + if [ "$ENABLE_CLAMAV" = 0 ]; then + _register_fix_function "_fix_cleanup_clamav" + fi ################### << fix funcs @@ -1050,6 +1053,12 @@ function _fix_var_amavis_permissions() { fi } +function _fix_cleanup_clamav() { + notify 'task' 'Cleaning up disabled Clamav' + rm -f /etc/logrotate.d/clamav-* + rm -f /etc/cron.d/freshclam +} + ########################################################################## # << Fix Stack ########################################################################## diff --git a/test/tests.bats b/test/tests.bats index e6d6db7c..be4ff2be 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -716,7 +716,7 @@ load 'test_helper/bats-assert/load' # @test "checking system: freshclam cron is enabled" { - run docker exec mail bash -c "crontab -l | grep '/usr/bin/freshclam'" + run docker exec mail bash -c "grep '/usr/bin/freshclam' -r /etc/cron.d" assert_success }