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