#!/bin/ksh
#
# OSSTech Dovecot
#
# chkconfig: - 65 35
# chkconfig.solaris: 2 88 36
# chkconfig.aix: 2 273 30
# description: Dovecot POP/IMAP Server

### BEGIN INIT INFO
# Provides: dovecot
# Required-Start:	$local_fs $remote_fs $network $syslog $time
# Required-Stop:	$local_fs $remote_fs $network $syslog
# Should-Start:		slapd winbind nslcd sssd
# Should-Stop:		slapd winbind nslcd sssd
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 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

. /opt/osstech/etc/sv/svinit || exit 1

sv_name="dovecot"

function sv_reload {
  sv_hangup "$1" "Reloading"
}

function svc {
  if [[ "${1-}" = "-d" ]]; then
    ## Send TERM signal to process group on stopping to
    ## work around dovecot/auth process delays exiting
    shift
    set - -+d ${1+"$@"}
  fi
  command svc ${1+"$@"}
}

sv_init "$sv_name" ${1+"$@"}

