#! /bin/sh

exec_prefix=/usr/local
sbindir=${exec_prefix}/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/authdaemonrc
if test "$version" != ""
then
	AUTHDAEMOND="$version"
fi

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