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