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