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