+ # Sanity check: If TMPMBOX exists and is 20 minutes old or less,
+ # there is some serious trouble, and we should (1) email
+ # postmaster about it and (2) block future processing of /var/mail
+ # until someone removes BLOCKFILE.
+ #
+ # If TMPMBOX exists and is older than 20 minutes, it's probably
+ # stale, so blow it away. Note that we will never get to this
+ # point if BLOCKFILE exists, so there is no need to refine the
+ # metric further.
+ if test -f $TMPMBOX; then
+ if test $(stat --format=%Y $TMPMBOX) -le \
+ $(date --date='-20 min' +%s); then
+ # Set block file
+ touch $BLOCKFILE
+ echo -e "/var/mail/$USER contains too much email." \
+ "\nBlocking email redelivery script until this is resolved." \
+ "\n\nTo indicate that this is resolved, do the following" \
+ "\non deleuze." \
+ "\n (1) Wait for $TMPMBOX to go away (should take an hour)" \
+ "\n (2) Run '$0 $USER'" \
+ "\n (3) Remove $BLOCKFILE" | \
+ mail -s "[redeliver-mail] Mail backlog too large on deleuze" \
+ -e -a "From: root@deleuze.hcoop.net" \
+ postmaster@deleuze.hcoop.net
+ exit 0
+ else
+ rm -fr $TMPMBOX
+ fi
+ fi
+