From 1d386cbe8597ab554c0c5c9e668879a2088d4881 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 24 Mar 2006 13:53:35 +0000 Subject: Mess with INBOX only if it exists (else locking works, but unlocking fails). --- localmb2md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'localmb2md') diff --git a/localmb2md b/localmb2md index fcdbdb3..5ee56ce 100755 --- a/localmb2md +++ b/localmb2md @@ -3,7 +3,7 @@ # /usr/local/sbin/adduser.local # Copyright 2005-2006 Jonas Smedegaard # -# $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 -- cgit v1.2.3