Re: mailfront imapfront-auth with dovecot 1.2.16 : SUCCESS

Giam Teck Choon <[email protected]> Sat, 13 Nov 2010 15:42:30 +0800
Newsgroups gmane.comp.sysutils.bgware
Organization CHOON.NET
Message-ID <[email protected]>
> Updated sh wrapper to support v1 and v2 and also see whether $MAIL is
> prefixed with maildir or mbox before modifying $MAIL accordingly. This
> wrapper also check $MAIL to see whether it is a directory to assume it
> is maildir or otherwise assume it is mbox:

Sorry, below is the updated sh wrapper as I should not grep $MAIL 
variable without echo it as it isn't a file:

--------------------8<----------8<----------8<----------8<---------------------
#!/bin/sh

DOVECOTIMAPOPTIONS=""
if [ -n "$MAIL" ] ; then
     # test to see whether maildir or mbox is prefixed in $MAIL
     checkmaildir=`echo $MAIL | grep -E '^maildir:'`
     checkmbox=`echo $MAIL | grep -E '^mbox:'`
     if [ ! -n "$checkmaildir" ] && [ ! -n "$checkmbox" ] ; then
	# if mailbox is a directory, assume it is maildir
	# otherwise assume it is mbox
	if [ -d "$MAIL" ] ; then
	    export MAIL=maildir:`echo $MAIL | sed 's@:@::@g'`
	else
	    export MAIL=mbox:`echo $MAIL | sed 's@:@::@g'`
	fi
     fi
     # we need to know dovecot is v1 or v2
     # as v1 is not supporting the options
     # -O -o mail_location=... ...
     if [ -x "/usr/sbin/dovecot" ] ; then
	dovecotversion=`/usr/sbin/dovecot --version | cut -f1 -d '.'`
	if [ "x$dovecotversion" == "x2" ] ; then
	    DOVECOTIMAPOPTIONS="-O -o mail_location=$MAIL"
	fi
     fi
fi
exec "$@" $DOVECOTIMAPOPTIONS
--------------------8<----------8<----------8<----------8<---------------------

Thanks.

Kindest regards,
Giam Teck Choon