From 260bfb8183789bd5c584bdac6d7a6cde39caadb0 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 6 Aug 2006 19:10:10 +0000 Subject: Make helpers non-configurable. init and promote new inbox even if no mailspool exists. --- localmb2md | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'localmb2md') 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 # -# $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 -- cgit v1.2.3