#!/bin/sh
# init script for the DBMail LMTP server
# you may need to make some changes to the following paths

# directory where the LMTP server executable resides
PROGDIR=/usr/local/sbin

# directory containing database shared libraries
# - multiple directories separated by a colon (':') are acceptable
# - if the LMTP server is statically linked, you may comment this out
DBLIBDIR=/usr/local/mysql/lib/mysql

# fully qualified filename of the DBMail configuration file
CONFIGFILE=/etc/dbmail.conf

# directory where the process ID of the LMTP server should be stored
# (this feature is not yet supported by DBMail)
PIDDIR=/var/run

##############################################################################
########### you should not have to change anything below this line ###########
##############################################################################

PROGRAM=dbmail-lmtpd
PIDFILE=$PIDDIR/$PROGRAM.pid
PATH=$PROGDIR:$PATH
export LD_LIBRARY_PATH=$DBLIBDIR:$LD_LIBRARY_PATH
export LIBPATH=$DBLIBDIR:$LIBPATH

# hopefully someday a pid file will be supported
OPTS="-f $CONFIGFILE -p $PIDFILE"

test -x $PROGDIR/$PROGRAM || exit 0

case "$1" in
    start)
	echo -n "Starting DBMail LMTP daemon ($PROGRAM) ... "
	$PROGRAM $OPTS
	echo "done."
    ;;

    stop)
	echo -n "Stopping DBMail LMTP daemon ... "
	kill `cat $PIDFILE`
	echo "done."
    ;;

    reload)
	$0 stop
	sleep 2
	$0 start
    ;;

    restart|force-reload)
	$0 reload
    ;;
    
    *)
	echo "Usage: $0 {start|stop|reload|restart|force-reload}" >&2
	exit 1
    ;;
esac

exit 0
