diff --git a/_modules/scripts/new_options.sh b/_modules/scripts/new_options.sh index 2c39c8a7c2..c509c91b46 100644 --- a/_modules/scripts/new_options.sh +++ b/_modules/scripts/new_options.sh @@ -280,7 +280,7 @@ adapt_new_options() { echo ENABLE_IPV6=${IPV6_BOOL} >> mailcow.conf ;; SKIP_CLAMD) - echo '# Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n' >> mailcow.conf + echo '# Skip ClamAV (clamd-mailcow) anti-virus - y/n' >> mailcow.conf echo 'SKIP_CLAMD=n' >> mailcow.conf ;; SKIP_OLEFY) diff --git a/data/Dockerfiles/rspamd/docker-entrypoint.sh b/data/Dockerfiles/rspamd/docker-entrypoint.sh index a764725cb7..d0876d09dd 100755 --- a/data/Dockerfiles/rspamd/docker-entrypoint.sh +++ b/data/Dockerfiles/rspamd/docker-entrypoint.sh @@ -104,6 +104,21 @@ EOF fi fi +CLAMD_AUTO_DISABLE_CONF=/etc/rspamd/override.d/antivirus.conf +if [[ "${SKIP_CLAMD}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + # Only auto-disable when antivirus.conf still points to the default local Mailcow + # ClamAV target. This avoids breaking custom external ClamAV setups. + if grep -Eq '^[[:space:]]*servers[[:space:]]*=[[:space:]]*"clamd:3310";' /etc/rspamd/local.d/antivirus.conf 2>/dev/null; then + cat < "${CLAMD_AUTO_DISABLE_CONF}" +clamav { + enabled = false; +} +EOF + fi +else + rm -f "${CLAMD_AUTO_DISABLE_CONF}" +fi + # Provide additional lua modules ln -s /usr/lib/$(uname -m)-linux-gnu/liblua5.1-cjson.so.0.0.0 /usr/lib/rspamd/cjson.so diff --git a/docker-compose.yml b/docker-compose.yml index 0a9578de6d..6b9e00c40d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -97,6 +97,7 @@ services: - REDIS_SLAVEOF_PORT=${REDIS_SLAVEOF_PORT:-} - REDISPASS=${REDISPASS} - SPAMHAUS_DQS_KEY=${SPAMHAUS_DQS_KEY:-} + - SKIP_CLAMD=${SKIP_CLAMD:-n} volumes: - ./data/hooks/rspamd:/hooks:Z - ./data/conf/rspamd/custom/:/etc/rspamd/custom:z diff --git a/generate_config.sh b/generate_config.sh index 420854eac4..3dc1d82704 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -322,7 +322,7 @@ SKIP_HTTP_VERIFICATION=n # Skip Unbound (DNS Resolver) Healthchecks (NOT Recommended!) - y/n SKIP_UNBOUND_HEALTHCHECK=n -# Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n +# Skip ClamAV (clamd-mailcow) anti-virus - y/n SKIP_CLAMD=${SKIP_CLAMD} # Skip Olefy (olefy-mailcow) anti-virus for Office documents (Rspamd will auto-detect a missing Olefy container) - y/n