summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2006-08-06 19:10:10 +0000
committerJonas Smedegaard <dr@jones.dk>2006-08-06 19:10:10 +0000
commit260bfb8183789bd5c584bdac6d7a6cde39caadb0 (patch)
tree8d7437082969ec0612b777f580dc88ddd03e5dd4
parentd621aa3802b4c34dbf7a224cedac84dab0b929e1 (diff)
Make helpers non-configurable. init and promote new inbox even if no mailspool exists.
-rwxr-xr-xlocalmb2md37
1 files changed, 26 insertions, 11 deletions
diff --git a/localmb2md b/localmb2md
index 0979ef5..ace50b5 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.8 2006-04-25 19:09:38 jonas Exp $
+# $Id: localmb2md,v 1.9 2006-08-06 19:10:10 jonas Exp $
#
# Convert user account from mailboxes below /var/mail/ and ~/mail/ to
# maildirs below ~/Maildir/ .
@@ -18,11 +18,8 @@
set -e
-helpers="/usr/bin/mb2md /usr/bin/mail-lock /usr/bin/mail-touchlock /usr/bin/mail-unlock"
-
# Unset these if the MDA delivers to Maildir without being told explicitly
mkprocmailrc="yes"
-helpers="$helpers /usr/bin/procmail"
# Change this to ".subscriptions" if using pre-1.xx Dovecot
subscriptions="subscriptions"
@@ -31,6 +28,11 @@ if [ -e /etc/local/mb2md.conf ]; then
. /etc/local/mb2md.conf
fi
+helpers="/usr/bin/mb2md /usr/bin/mail-lock /usr/bin/mail-touchlock /usr/bin/mail-unlock"
+if [ -n "$mkprocmailrc" ]; then
+ helpers="$helpers /usr/bin/procmail"
+fi
+
# Make sure all required tools are available
for prg in $helpers; do
if [ ! -x "$prg" ]; then
@@ -56,6 +58,18 @@ EOF
fi
fi
+init_inbox() {
+ mkdir -p ~/Maildir/cur ~/Maildir/new ~/Maildir/tmp
+ chmod -R u=rw,go=,u+X ~/Maildir
+}
+
+promote_inbox() {
+ if [ -n "$mkprocmailrc" ]; then
+ echo 'DEFAULT=$HOME/Maildir/' > ~/.procmailrc
+ fi
+ mkprocmailrc=''
+}
+
# Avoid incoming mail while messing with INBOX
if [ -e "/var/mail/$USER" ]; then
echo "Locking INBOX"
@@ -64,18 +78,15 @@ if [ -e "/var/mail/$USER" ]; then
# Save the PID of the mail-touchlock process
BADGER="$!"
- # Create Maildir for INBOX if not there already
- mkdir -p ~/Maildir/cur ~/Maildir/new ~/Maildir/tmp
- chmod -R u=rw,go=,u+X ~/Maildir
+ init_inbox
# Convert INBOX if not empty
if [ -s "/var/mail/$USER" ]; then
mb2md -m
fi
- # Reroute future incoming mail to Maildir
- if [ -n "$mkprocmailrc" ]; then
- echo 'DEFAULT=$HOME/Maildir/' > ~/.procmailrc
- fi
+
+ promote_inbox
+
# Purge old INBOX
echo -n '' > "/var/mail/$USER"
@@ -85,6 +96,10 @@ if [ -e "/var/mail/$USER" ]; then
echo "INBOX unlocked again"
fi
+# We want inbox initialized and promoted, even if no mailspool existed
+init_inbox
+promote_inbox
+
# Convert secondary mailboxes
if [ -d ~/mail ]; then
mv ~/mail ~/mail.abandoned