diff options
-rwxr-xr-x | localmb2md | 41 |
1 files changed, 21 insertions, 20 deletions
@@ -3,7 +3,7 @@ # /usr/local/sbin/adduser.local # Copyright 2005-2006 Jonas Smedegaard <dr@jones.dk> # -# $Id: localmb2md,v 1.4 2006-01-18 11:25:34 jonas Exp $ +# $Id: localmb2md,v 1.5 2006-03-24 13:53:35 jonas Exp $ # # Convert user account from mailboxes below /var/mail/ and ~/mail/ to # maildirs below ~/Maildir/ . @@ -36,28 +36,29 @@ if [ -f ~/.procmailrc ] && egrep -v -q '^DEFAULT=\$HOME/Maildir/$' ~/.procmailrc exit 1 fi - # Avoid incoming mail while messing with INBOX -mail-lock -mail-touchlock & -# Save the PID of the mail-touchlock process -BADGER="$!" +if [ -e "/var/mail/$USER" ]; then + mail-lock + mail-touchlock & + # Save the PID of the mail-touchlock process + BADGER="$!" -# Convert INBOX and purge if not empty -if [ -s "/var/mail/$USER" ]; then - mb2md -m - echo -n '' > "/var/mail/$USER" -else - # Create Maildir for INBOX if not there already - mkdir -p ~/Maildir/cur ~/Maildir/new ~/Maildir/tmp - chmod -R u=rw,go=,u+X ~/Maildir -fi -# Reroute future incoming mail to Maildir -echo 'DEFAULT=$HOME/Maildir/' > ~/.procmailrc + # Convert INBOX and purge if not empty + if [ -s "/var/mail/$USER" ]; then + mb2md -m + echo -n '' > "/var/mail/$USER" + else + # Create Maildir for INBOX if not there already + mkdir -p ~/Maildir/cur ~/Maildir/new ~/Maildir/tmp + chmod -R u=rw,go=,u+X ~/Maildir + fi + # Reroute future incoming mail to Maildir + echo 'DEFAULT=$HOME/Maildir/' > ~/.procmailrc -# Allow incoming mail again -kill "${BADGER}" -mail-unlock + # Allow incoming mail again + kill "${BADGER}" + mail-unlock +fi # Convert secondary mailboxes if [ -d ~/mail ]; then |