2007-01-16 00:07:58 +01:00
|
|
|
#! /bin/sh
|
|
|
|
# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Author: Thorsten Kukuk <feedback@suse.de>
|
|
|
|
#
|
|
|
|
# /etc/init.d/courier-pop
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: courier-pop
|
|
|
|
# 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-POP3 server
|
|
|
|
# Description: Start the Courier-POP3 server, which is an
|
|
|
|
# POP3 server for Maildir mailboxes.
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Check for missing binaries (stale symlinks should not happen)
|
|
|
|
POP3_BIN=/usr/sbin/pop3d
|
|
|
|
test -x $POP3_BIN || exit 5
|
|
|
|
|
|
|
|
. /etc/rc.status
|
|
|
|
|
|
|
|
# Read configuration
|
|
|
|
. /etc/courier/pop3d
|
|
|
|
test "$MAILDIRPATH" == "" && MAILDIRPATH=Maildir
|
|
|
|
test "$PIDFILE" == "" && PIDFILE=/var/run/pop3d.pid
|
2009-09-02 00:10:28 +02:00
|
|
|
LOCKFILE=${PIDFILE}.lock
|
2007-01-16 00:07:58 +01:00
|
|
|
|
|
|
|
# Reset status of this service
|
|
|
|
rc_reset
|
|
|
|
|
2009-09-02 00:10:28 +02:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2007-01-16 00:07:58 +01:00
|
|
|
case "$1" in
|
|
|
|
start)
|
2009-09-02 00:10:28 +02:00
|
|
|
/etc/init.d/courier-authdaemon status > /dev/null || /etc/init.d/courier-authdaemon start
|
2007-01-16 00:07:58 +01:00
|
|
|
echo -n "Starting Courier-POP3 "
|
|
|
|
/usr/bin/env - /bin/sh -c " set -a ;
|
|
|
|
. /etc/courier/pop3d ; \
|
2009-09-02 00:10:28 +02:00
|
|
|
grep POP3_STARTTLS=NO /etc/courier/pop3d-ssl &>/dev/null || . /etc/courier/pop3d-ssl ; \
|
|
|
|
POP3_STARTTLS=$POP3_STARTTLS ; export POP3_STARTTLS ; \
|
2007-01-16 00:07:58 +01:00
|
|
|
PROXY_HOSTNAME=$PROXY_HOSTNAME ; \
|
2009-09-02 00:10:28 +02:00
|
|
|
TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL ; \
|
2007-01-16 00:07:58 +01:00
|
|
|
/usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \
|
|
|
|
/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
|
|
|
|
-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP $TCPDOPTS \
|
|
|
|
$PORT /usr/sbin/pop3login \
|
|
|
|
$POP3_BIN ${MAILDIRPATH}"
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status and be verbose
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Shutting down Courier-POP3 "
|
|
|
|
/usr/sbin/courierlogger -pid=$PIDFILE -stop
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status and be verbose
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status -v
|
|
|
|
rm -f $PIDFILE{,.lock}
|
|
|
|
;;
|
|
|
|
try-restart)
|
|
|
|
$0 status >/dev/null && $0 restart
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
echo -n "Reload Courier-POP3 "
|
|
|
|
$0 stop && $0 start
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
echo -n "Reload Courier-POP3 "
|
|
|
|
rc_failed 3
|
2009-09-02 00:10:28 +02:00
|
|
|
|
|
|
|
# Remember status and be verbose
|
2007-01-16 00:07:58 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
echo -n "Checking for Courier-POP3 "
|
2009-09-02 00:10:28 +02:00
|
|
|
## 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 "$PIDFILE" "$LOCKFILE"
|
|
|
|
|
|
|
|
#Remeber status and be verbose
|
|
|
|
rc_status -v
|
2007-01-16 00:07:58 +01:00
|
|
|
;;
|
|
|
|
*)
|
2009-09-02 00:10:28 +02:00
|
|
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
2007-01-16 00:07:58 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
rc_exit
|