From 83880da90618130005b3470bb95323a320424f1a Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Tue, 16 Jul 2019 16:20:19 +0200 Subject: [PATCH] Changed the postgrey update script to run daily, but check if the file is older than 28 days --- setup/mail-postfix.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/setup/mail-postfix.sh b/setup/mail-postfix.sh index e67fab28..a554ed65 100755 --- a/setup/mail-postfix.sh +++ b/setup/mail-postfix.sh @@ -212,13 +212,27 @@ tools/editconf.py /etc/default/postgrey \ # We are going to setup a newer whitelist for postgrey, the version included in the distribution is old -cat > /etc/cron.monthly/mailinabox-postgrey-whitelist << EOF; +cat > /etc/cron.daily/mailinabox-postgrey-whitelist << EOF; #!/bin/bash + # Mail-in-a-Box -curl https://postgrey.schweikert.ch/pub/postgrey_whitelist_clients --output /etc/postgrey/whitelist_clients -sS --fail > /dev/null 2>&1 + +# check we have a postgrey_whitelist_clients file and that it is not older than 28 days +if [ ! -f /etc/postgrey/whitelist_clients ] || find /etc/postgrey/whitelist_clients -mtime +28 ; then + # ok we need to update the file, so lets try to fetch it + if curl https://postgrey.schweikert.ch/pub/postgrey_whitelist_clients --output /tmp/postgrey_whitelist_clients -sS --fail > /dev/null 2>&1 ; then + # if fetching hasn't failed yet then check it is a plain text file + # curl manual states that --fail sometimes still produces output + # this final check will at least check the output is not html + # before moving it into place + if [ $( file -b --mime-type /tmp/postgrey_whitelist_clients) == "text/plain" ]; then + mv /tmp/postgrey_whitelist_clients /etc/postgrey/whitelist_clients + fi + fi +fi EOF -chmod +x /etc/cron.monthly/mailinabox-postgrey-whitelist -/etc/cron.monthly/mailinabox-postgrey-whitelist +chmod +x /etc/cron.daily/mailinabox-postgrey-whitelist +/etc/cron.daily/mailinabox-postgrey-whitelist # Increase the message size limit from 10MB to 128MB. # The same limit is specified in nginx.conf for mail submitted via webmail and Z-Push.