X-Git-Url: http://git.hcoop.net/clinton/scripts.git/blobdiff_plain/5debfe01c15938323eafca20f3b69b8f31e69b3c..d96599bf6b2ac9eb4ee176d86ac93666007694ad:/redeliver-mail diff --git a/redeliver-mail b/redeliver-mail new file mode 100755 index 0000000..0d68870 --- /dev/null +++ b/redeliver-mail @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Redeliver any messages that may have accidentally been sent to +# /var/mail/$USER, due to temporary AFS glitches. +# +# This should be called as root on deleuze. + +for MBOX in /var/mail/*; do + + USER=$(basename $MBOX) + TMPMBOX=/tmp/exim4/$USER.mbox.tmp + + # Sanity check: file exists and has nonzero size + if ! test -s $MBOX; then + continue + fi + + # Deliver mail. If the message still can't be written to + # $USER/Maildir, Exim will place it in /var/mail/$USER again. + mv /var/mail/$USER $TMPMBOX + formail -s /etc/exim4/deliver-once $USER < $TMPMBOX + rm -f $TMPMBOX +done