X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mailtest-check;h=7454086099322db19eec59bee04471d555fc297d;hb=d7551546ac323c5d4b49370c885646bcf96e959f;hp=2dcc7b215a7bc4cb748c98191f0953d809756f5b;hpb=7c94d9bd37b13d57098a297e1e58ad27b54e6eff;p=distro-setup diff --git a/mailtest-check b/mailtest-check index 2dcc7b2..7454086 100755 --- a/mailtest-check +++ b/mailtest-check @@ -21,7 +21,9 @@ e() { $int || return 0; printf "mailtest-check: %s\n" "$*"; } # We run this cronjob along with sending the test email every 5 minutes, # so give it 1 minute to arrive, then if the latest email is older than # 7 minutes, the last 2 haven't arrived in a reasonable amount of time. -min_limit=8 +# However, when machines reboot things can get delayed, so add 10 mins, +# not sure if that is a good number or not. +min_limit=17 # spamassassin checking takes about 8 seconds. only do that every @@ -76,7 +78,14 @@ esac getspamdpid() { if [[ ! $spamdpid || ! -d /proc/$spamdpid ]]; then - spamdpid=$(systemctl show --property MainPID --value spamassassin | sed 's/^1$//' ||:) + # try twice in case we are restarting, it happens. + for i in 1 2; do + spamdpid=$(systemctl show --property MainPID --value spamassassin | sed 's/^[10]$//' ||:) + if [[ $spamdpid ]]; then + break + fi + sleep 30 + done fi } getspamdpid @@ -133,7 +142,8 @@ for folder in ${folders[@]}; do # servers. # example line that sed is parsing: # (-0.1 / 5.0 requ) DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,SPF_HELO_PASS=-0.001,SPF_PASS=-0.001,TVD_SPACE_RATIO=0.001 autolearn=_AUTOLEARN - for r in $($spamcpre sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$latest" | tail -n2 | head -n1 | sed -r 's/^\([^)]*\) *//;s/=[^, ]*([, ]|$)/ /g'); do + raw_results="$($spamcpre sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$latest" | tail -n2 | head -n1 | sed -r 's/^\([^)]*\) *//;s/=[^, ]*([, ]|$)/ /g')" + for r in $raw_results; do case $r in # got this in an update 2022-01. dun care T_SCC_BODY_TEXT_LINE|SCC_BODY_SINGLE_WORD) : ;;