#!/sbin/sh

PID=/var/run/dovecot/master.pid
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH

case "$1" in 
'refresh')
	if [ -f /usr/local/etc/dovecot.conf ]; then
		kill -HUP `cat $PID`
	fi	
        ;;

'start')
	if [ -f /usr/local/etc/dovecot.conf ]; then
		/usr/local/sbin/dovecot
	fi	
	;;

'stop')
	if [ -f $PID ]; then
		kill -QUIT `cat $PID` || true
	fi
	;;

*)
	echo "Usage: $0 { start | stop | refresh }"
	exit 1
	;;
esac
exit 0
