#! /bin/sh

exec_prefix=/usr
sbindir=/usr/sbin
DIR=`dirname $0`

AUTHDAEMOND=authdaemond.plain

if test -x $DIR/authdaemond.ldap
then
	AUTHDAEMOND=authdaemond.ldap
fi

if test -x $DIR/authdaemond.mysql
then
	AUTHDAEMOND=authdaemond.mysql
fi

if test -x $DIR/authdaemond.pgsql
then
	AUTHDAEMOND=authdaemond.pgsql
fi

. /etc/courier-imap/authdaemon.conf
if test "$version" != ""
then
	AUTHDAEMOND="$version"
fi

export DEBUG_LOGIN
exec ${sbindir}/courierlogger -pid=/var/lib/courier-imap/pid -$1 $DIR/$AUTHDAEMOND
