From: Ian Kelling Date: Mon, 9 Nov 2020 03:32:07 +0000 (-0500) Subject: more thorough mail testing X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=20077c84dc52b7e473249dd77994ceb9ca4c8f4d;p=distro-setup more thorough mail testing --- diff --git a/mailtest-check b/mailtest-check index 2ab174e..59b7dce 100755 --- a/mailtest-check +++ b/mailtest-check @@ -9,44 +9,52 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPES shopt -s nullglob +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=7 +int=true if [[ ! $1 && $- != *i* ]]; then + int=false sleep 60 fi -folder=/m/md/l/testignore +folders=(/m/md/l/testignore{,zroe}) case $HOSTNAME in bk) - folder=/m/md/expertpathologyreview.com/testignore + folders=(/m/md/{expertpathologyreview.com,amnimal.ninja}/testignore) ;; je) - folder=/m/md/je.b8.nz/testignore + folders=(/m/md/je.b8.nz/testignore) ;; esac -find $folder/new $folder/cur -type f -mmin +300 -delete - -cd $folder -last_sec=0 -# webmail sends them to cur it seems -for file in new/* cur/*; do - if [[ $file -nt $latest ]]; then - latest=$file +for folder in ${folders[@]}; do + + find $folder/new $folder/cur -type f -mmin +300 -delete + cd $folder + last_sec=0 + # webmail sends them to cur it seems + for file in new/* cur/*; do + if [[ $file -nt $latest ]]; then + latest=$file + fi + done + + if [[ $latest ]]; then + e latest = $folder/$latest + last_sec=$(awk '/^Subject: / {print $4}' $latest) fi -done -if [[ $latest ]]; then - last_sec=$(awk '/^Subject: / {print $4}' $latest) -fi + now=$(date +%s) + limit=$(( now - 60 * min_limit )) -now=$(date +%s) -limit=$(( now - 60 * min_limit )) - -if (( last_sec <= limit )); then - echo $HOSTNAME mailtest failure $(date -d @$last_sec +'%a %m-%d %H:%M') -fi + if (( last_sec <= limit )); then + echo $HOSTNAME mailtest $folder $(date -d @$last_sec +'%a %m-%d %H:%M') + fi +done