8f30fd
#!/bin/bash
8f30fd
#
8f30fd
#	/etc/rc.d/init.d/dovecot
8f30fd
#
8f30fd
# Starts the dovecot daemon
8f30fd
#
8f30fd
# chkconfig: - 65 35
8f30fd
# description: Dovecot Imap Server
8f30fd
# processname: dovecot
8f30fd
# config: /etc/dovecot.conf
8f30fd
# config: /etc/sysconfig/dovecot
8f30fd
# pidfile: /var/run/dovecot/master.pid
8f30fd
8f30fd
### BEGIN INIT INFO
8f30fd
# Provides: dovecot
8f30fd
# Required-Start: $local_fs $network
8f30fd
# Required-Stop: $local_fs $network
8f30fd
# Should-Start: $remote_fs
8f30fd
# Should-Stop: $remote_fs
8f30fd
# Default-Start: 
8f30fd
# Default-Stop: 0 1 2 3 4 5 6
8f30fd
# Short-Description: start and stop Dovecot Imap server
8f30fd
# Description: Dovecot is an IMAP server for Linux/UNIX-like systems,
8f30fd
#              written with security primarily in mind.  It also contains
8f30fd
#              a small POP3 server.
8f30fd
### END INIT INFO
8f30fd
8f30fd
# Source function library.
8f30fd
. /etc/init.d/functions
8f30fd
8f30fd
if [ -f /etc/sysconfig/dovecot -a $UID -eq 0 ]; then
8f30fd
    . /etc/sysconfig/dovecot
8f30fd
fi
8f30fd
8f30fd
RETVAL=0
8f30fd
prog="Dovecot Imap"
8f30fd
exec="/usr/sbin/dovecot"
8f30fd
config="/etc/dovecot/dovecot.conf"
8f30fd
pidfile="/var/run/dovecot/master.pid"
8f30fd
lockfile="/var/lock/subsys/dovecot"
8f30fd
8f30fd
start() {
8f30fd
	[ $UID -eq 0 ] || exit 4
8f30fd
	[ -x $exec ] || exit 5
8f30fd
	[ -f $config ] || exit 6
8f30fd
8f30fd
        echo -n $"Starting $prog: "
8f30fd
	daemon --pidfile $pidfile $exec $OPTIONS
8f30fd
	RETVAL=$?
8f30fd
	[ $RETVAL -eq 0 ] && touch  $lockfile
8f30fd
	echo
8f30fd
}
8f30fd
8f30fd
stop() {
8f30fd
	[ $UID -eq 0 ] || exit 4
8f30fd
	echo -n $"Stopping $prog: "
8f30fd
	killproc -p $pidfile $exec
8f30fd
	RETVAL=$?
8f30fd
	[ $RETVAL -eq 0 ] && rm -f $lockfile
8f30fd
	echo
8f30fd
}
8f30fd
8f30fd
reload() {
8f30fd
	[ $UID -eq 0 ] || exit 4
8f30fd
	echo -n $"Reloading $prog: "
8f30fd
	killproc -p $pidfile $exec -HUP
8f30fd
	RETVAL=$?
8f30fd
	echo
8f30fd
}
8f30fd
8f30fd
#
8f30fd
#	See how we were called.
8f30fd
#
8f30fd
case "$1" in
8f30fd
  start)
8f30fd
	start
8f30fd
	;;
8f30fd
  stop)
8f30fd
	stop
8f30fd
	;;
8f30fd
  reload)
8f30fd
	reload
8f30fd
	;;
8f30fd
  force-reload|restart)
8f30fd
	stop
8f30fd
	sleep 1
8f30fd
	start
8f30fd
	RETVAL=$?
8f30fd
	;;
8f30fd
  condrestart|try-restart)
8f30fd
	if [ -f $lockfile ]; then
8f30fd
	    stop
8f30fd
	    sleep 3
8f30fd
	    start
8f30fd
	fi
8f30fd
	;;
8f30fd
  status)
8f30fd
	status -p $pidfile $exec
8f30fd
	RETVAL=$?
8f30fd
	;;
8f30fd
  *)
8f30fd
	echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|reload|force-reload|status}"
8f30fd
	RETVAL=2
8f30fd
	[ "$1" = 'usage' ] && RETVAL=0
8f30fd
esac
8f30fd
8f30fd
exit $RETVAL
8f30fd