X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=filesystem%2Fusr%2Flocal%2Fbin%2Fmailtest-check;h=c48fae99b4e0a702540384be262c578a53a09d09;hb=4d0dc703ef2e62cd16ea84f27456f6f50f74baa3;hp=73f3b33209ed84c16a826fd660fcb9154b9a1eeb;hpb=f7eaad64a7c5f3bc851f146e1f258d34f398a7d7;p=distro-setup diff --git a/filesystem/usr/local/bin/mailtest-check b/filesystem/usr/local/bin/mailtest-check index 73f3b33..c48fae9 100755 --- a/filesystem/usr/local/bin/mailtest-check +++ b/filesystem/usr/local/bin/mailtest-check @@ -2,9 +2,21 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +if [[ $EUID != 1000 ]]; then + echo "$0: error run as normal user" >&2 + exit 1 +fi + cd /m/md/l/testignore/new shopt -s nullglob +# we run this cronjob along with sending the test email every 10 +# minutes, so give it 2 minutes to arrive, then if there is an email at +# least 23 minutes old, the last 2 test emails have failed. +if [[ ! $1 && $- != *i* ]]; then + sleep 120 +fi + last_sec=0 for file in *; do if [[ $file -nt $latest ]]; then @@ -17,13 +29,13 @@ if [[ $latest ]]; then fi now=$(date +%s) -limit=$(( now - 60 * 22 )) +limit=$(( now - 60 * 23 )) -if (( last_sec < limit )); then +if (( last_sec <= limit )); then echo $HOSTNAME mailtest failure - touch /nocow/mailtest-failure + touch /nocow/user/mailtest-failure else - rm -f /nocow/mailtest-failure + rm -f /nocow/user/mailtest-failure fi -find -type f -mtime +1 -delete +find . -type f -mtime +1 -delete