73f3b33209ed84c16a826fd660fcb9154b9a1eeb
[distro-setup] / filesystem / usr / local / bin / mailtest-check
1 #!/bin/bash
2 set -eE -o pipefail
3 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
4
5 cd /m/md/l/testignore/new
6 shopt -s nullglob
7
8 last_sec=0
9 for file in *; do
10 if [[ $file -nt $latest ]]; then
11 latest=$file
12 fi
13 done
14
15 if [[ $latest ]]; then
16 last_sec=$(awk '/^Subject: / {print $3}' $latest)
17 fi
18
19 now=$(date +%s)
20 limit=$(( now - 60 * 22 ))
21
22 if (( last_sec < limit )); then
23 echo $HOSTNAME mailtest failure
24 touch /nocow/mailtest-failure
25 else
26 rm -f /nocow/mailtest-failure
27 fi
28
29 find -type f -mtime +1 -delete