From cb50d08605875e4f1862d6309e3ff9145423c9ad Mon Sep 17 00:00:00 2001 From: Niklas Meyer Date: Mon, 19 Aug 2024 11:08:13 +0200 Subject: [PATCH] dovecot: added timeout option when sa-rules cannot be downloaded (#6025) * dovecot: added timeout option when sa-rules cannot be downloaded * dovecot: changed sa-rules exit code to 0 to allow dovecot to start afterwards --- data/Dockerfiles/dovecot/sa-rules.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/data/Dockerfiles/dovecot/sa-rules.sh b/data/Dockerfiles/dovecot/sa-rules.sh index 107ea7172..2a513805a 100755 --- a/data/Dockerfiles/dovecot/sa-rules.sh +++ b/data/Dockerfiles/dovecot/sa-rules.sh @@ -11,10 +11,14 @@ else fi # Deploy -curl --connect-timeout 15 --retry 10 --max-time 30 https://www.spamassassin.heinlein-support.de/$(dig txt 1.4.3.spamassassin.heinlein-support.de +short | tr -d '"' | tr -dc '0-9').tar.gz --output /tmp/sa-rules-heinlein.tar.gz -if gzip -t /tmp/sa-rules-heinlein.tar.gz; then - tar xfvz /tmp/sa-rules-heinlein.tar.gz -C /tmp/sa-rules-heinlein - cat /tmp/sa-rules-heinlein/*cf > /etc/rspamd/custom/sa-rules +if curl --connect-timeout 15 --retry 10 --max-time 30 https://www.spamassassin.heinlein-support.de/$(dig txt 1.4.3.spamassassin.heinlein-support.de +short | tr -d '"' | tr -dc '0-9').tar.gz --output /tmp/sa-rules-heinlein.tar.gz; then + if gzip -t /tmp/sa-rules-heinlein.tar.gz; then + tar xfvz /tmp/sa-rules-heinlein.tar.gz -C /tmp/sa-rules-heinlein + cat /tmp/sa-rules-heinlein/*cf > /etc/rspamd/custom/sa-rules + fi +else + echo "Failed to download SA rules. Exiting." + exit 0 # Must be 0 otherwise dovecot would not start at all fi sed -i -e 's/\([^\\]\)\$\([^\/]\)/\1\\$\2/g' /etc/rspamd/custom/sa-rules