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