summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2006-03-24 13:53:35 +0000
committerJonas Smedegaard <dr@jones.dk>2006-03-24 13:53:35 +0000
commit1d386cbe8597ab554c0c5c9e668879a2088d4881 (patch)
treee6e046b65d9faeae1c12e2d3ab4e30244da1b98c
parent17de03ec19a320216cd0eecdd3c1a7fd9091c702 (diff)
Mess with INBOX only if it exists (else locking works, but unlocking fails).
-rwxr-xr-xlocalmb2md41
1 files changed, 21 insertions, 20 deletions
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 <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