forked from pool/courier-imap
49551189e5
Copy from server:mail/courier-imap based on submit request 18563 from user hennevogel OBS-URL: https://build.opensuse.org/request/show/18563 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/courier-imap?expand=0&rev=18
147 lines
3.5 KiB
Bash
147 lines
3.5 KiB
Bash
#! /bin/sh
|
|
# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
# All rights reserved.
|
|
#
|
|
# Author: Thorsten Kukuk <feedback@suse.de>
|
|
#
|
|
# /etc/init.d/courier-imap-ssl
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: courier-imap-ssl
|
|
# Required-Start: $syslog $remote_fs courier-authdaemon
|
|
# Should-Start:
|
|
# Required-Stop: $syslog $remote_fs
|
|
# Should-Stop:
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 6
|
|
# Short-Description: Courier-IMAP server for SSL connections
|
|
# Description: Start the Courier-IMAP server, which is an
|
|
# IMAP server for Maildir mailboxes. This
|
|
# version only accepts SSL connections.
|
|
### END INIT INFO
|
|
|
|
# Check for missing binaries (stale symlinks should not happen)
|
|
IMAP_BIN=/usr/sbin/imapd
|
|
test -x $IMAP_BIN || exit 5
|
|
|
|
. /etc/rc.status
|
|
|
|
# Read configuration
|
|
TLS_CACHEFILE=""
|
|
. /etc/courier/imapd
|
|
. /etc/courier/imapd-ssl
|
|
test "$MAILDIRPATH" == "" && MAILDIRPATH=Maildir
|
|
test "$PIDFILE" == "" && PIDFILE=/var/run/imapd.pid
|
|
test "$SSLPIDFILE" == "" && SSLPIDFILE=/var/run/imapd-ssl.pid
|
|
LOCKFILE=${SSLPIDFILE}.lock
|
|
|
|
# Reset status of this service
|
|
rc_reset
|
|
|
|
# our version of check_proc
|
|
#IN: $PIDFILE $LOCKFILE
|
|
check_proc(){
|
|
# check for process
|
|
ps auxw | grep -v grep | grep $1 >/dev/null
|
|
RET=$?
|
|
if [ $RET = "1" ]; then
|
|
if [ -f $1 ]; then
|
|
ERR=1
|
|
elif [ -f $2 ]; then
|
|
ERR=2
|
|
else
|
|
ERR=3
|
|
fi
|
|
else
|
|
ERR=$RET
|
|
fi
|
|
STATUS=$ERR
|
|
return $STATUS
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
/etc/init.d/courier-authdaemon status > /dev/null || /etc/init.d/courier-authdaemon start
|
|
echo -n "Starting Courier-IMAP (SSL)"
|
|
if test ! -f $TLS_CERTFILE
|
|
then
|
|
echo -n " generating-SSL-certificate..."
|
|
/usr/sbin/mkimapdcert >/dev/null 2>&1
|
|
fi
|
|
if test "$TLS_CACHEFILE" != ""
|
|
then
|
|
rm -f $TLS_CACHEFILE
|
|
fi
|
|
umask $IMAP_UMASK
|
|
ulimit -v $IMAP_ULIMITD
|
|
/usr/bin/env - /bin/sh -c " set -a ;
|
|
. /etc/courier/imapd ; \
|
|
. /etc/courier/imapd-ssl ; \
|
|
IMAP_TLS=1; export IMAP_TLS; \
|
|
PROXY_HOSTNAME=$PROXY_HOSTNAME ; \
|
|
/usr/sbin/courierlogger -pid=$SSLPIDFILE -start $SSLLOGGEROPTS \
|
|
/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
|
|
-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP $TCPDOPTS \
|
|
$SSLPORT $COURIERTLS -server -tcpd /usr/sbin/imaplogin \
|
|
$IMAP_BIN ${MAILDIRPATH}"
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
;;
|
|
stop)
|
|
echo -n "Shutting down Courier-IMAP (SSL)"
|
|
/usr/sbin/courierlogger -pid=$SSLPIDFILE -stop
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
rm -f $SSLPIDFILE{,.lock}
|
|
;;
|
|
try-restart)
|
|
$0 status >/dev/null && $0 restart
|
|
|
|
# Remember status
|
|
rc_status
|
|
;;
|
|
restart)
|
|
$0 stop
|
|
$0 start
|
|
|
|
# Remember status
|
|
rc_status
|
|
;;
|
|
force-reload)
|
|
echo -n "Reload Courier-IMAP (SSL)"
|
|
$0 stop && $0 start
|
|
|
|
# Remember status
|
|
rc_status
|
|
;;
|
|
reload)
|
|
echo -n "Reload Courier-IMAP (SSL)"
|
|
rc_failed 3
|
|
|
|
# Remember status and be verbose
|
|
rc_status -v
|
|
;;
|
|
status)
|
|
echo -n "Checking for Courier-IMAP (SSL)"
|
|
## Check status with checkproc(8), if process is running
|
|
## checkproc will return with exit status 0.
|
|
|
|
# Status has a slightly different for the status command:
|
|
# 0 - service running
|
|
# 1 - service dead, but /var/run/ pid file exists
|
|
# 2 - service dead, but /var/lock/ lock file exists
|
|
# 3 - service not running
|
|
check_proc "$SSLPIDFILE" "$LOCKFILE"
|
|
|
|
# Remeber status and be verbose
|
|
rc_status -v
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
rc_exit
|