#!/bin/sh
#
# /etc/rc.d/dovecot: start/stop dovecot IMAP/POP3 daemon
#

KEY=/etc/ssl/keys/dovecot.key
CRT=/etc/ssl/certs/dovecot.crt

case $1 in
start)
	if [ ! -s $KEY -o ! -s $CRT ]; then 
		/usr/bin/mksslcert $KEY $CRT
	fi
	/usr/sbin/dovecot
	;;
stop)
	killall -q /usr/sbin/dovecot
	;;
restart)
	$0 stop
	sleep 2
	$0 start
	;;
reload)
	kill -s SIGHUP $(pidof dovecot)
	;;
*)
	echo "usage: $0 [start|stop|restart|reload]"
	;;
esac

# End of file
