From: mwolson_admin Date: Fri, 19 Oct 2007 18:27:44 +0000 (-0400) Subject: redeliver-mail: new script to redeliver all mail in /var/mail X-Git-Url: https://git.hcoop.net/hcoop/scripts.git/commitdiff_plain/e9472285f78a5bf3f981df3de6f386d7ced94d55?ds=sidebyside redeliver-mail: new script to redeliver all mail in /var/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