PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 5ms RepoModel.GetById 15ms app.codeStats 0ms

/rc0.d/K20courier-pop

http://github.com/brinkman83/bashrc
Shell | 105 lines | 78 code | 15 blank | 12 comment | 11 complexity | 01563971b66842f9b93e18aa95ab6fea MD5 | raw file
  1#! /bin/sh -e
  2### BEGIN INIT INFO
  3# Short-Description: Courier POP3 server
  4# Provides:          courier-pop
  5# Required-Start:    $remote_fs $syslog
  6# Required-Stop:     $remote_fs $syslog
  7# Default-Start:     2 3 4 5
  8# Default-Stop:      0 1 6
  9# Description:       courier-pop is an POP3 Mail Delivery Agent.
 10### END INIT INFO
 11
 12prefix="/usr"
 13exec_prefix=${prefix}
 14sysconfdir="/etc/courier"
 15sbindir="${exec_prefix}/sbin"
 16libexecdir="${prefix}/lib/courier"
 17run_dir="/var/run/courier"
 18calendar_dir="/var/run/courier/calendar"
 19TCPD="${sbindir}/couriertcpd"
 20DAEMON=${sbindir}/pop3d
 21PROGRAM="Courier POP3 server"
 22PROG="pop3d"
 23SSLCONFIG=
 24
 25test -f $DAEMON || exit 0
 26
 27. /lib/lsb/init-functions
 28
 29if [ ! -d ${run_dir} ]; then
 30        mkdir -p ${run_dir}
 31        chown daemon:daemon ${run_dir}
 32fi
 33
 34if [ ! -d ${calendar_dir} ]; then
 35        mkdir -p ${calendar_dir}
 36        chown daemon:daemon ${calendar_dir}
 37fi
 38
 39
 40
 41if ! [ -x $TCPD ]; then
 42  log_failure_msg "ERR: $TCPD missing"
 43  exit 1
 44fi
 45
 46if ! [ -f ${sysconfdir}/pop3d ]; then
 47  log_failure_msg "ERR: config file missing"
 48  exit 1
 49fi
 50
 51# read/set defaults
 52if [ -f /etc/default/courier ]; then
 53	. /etc/default/courier
 54fi
 55# ensure that maildirpath is set
 56if [ -z "$MAILDIRPATH" ]; then
 57	MAILDIRPATH=Maildir
 58fi
 59
 60if [ -f "${sysconfdir}/pop3d-ssl" ]; then
 61	. "${sysconfdir}/pop3d-ssl"
 62	SSLCONFIG=1
 63fi
 64. ${sysconfdir}/pop3d
 65
 66START=no
 67case "$POP3DSTART" in
 68  [yY]*)START=yes;;
 69esac
 70
 71case "$1" in
 72start)
 73  if [ "$START" = "yes" ]; then
 74    log_begin_msg "Starting $PROGRAM..."
 75
 76    /usr/bin/env - /bin/sh -c " set -a; \
 77		. ${sysconfdir}/pop3d; \
 78		if [ "$SSLCONFIG" ]; then . ${sysconfdir}/pop3d-ssl; fi; \
 79		POP3_STARTTLS=$POP3_STARTTLS; export POP3_STARTTLS; \
 80		TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL; \
 81		/usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \
 82	    $TCPD \
 83		-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
 84		$TCPDOPTS -address=$ADDRESS $PORT \
 85		${libexecdir}/courier/courierpop3login $AUTHMODULELIST \
 86		${libexecdir}/courier/courierpop3d $MAILDIRPATH"
 87    log_end_msg 0
 88  fi
 89    ;;
 90stop)
 91  log_begin_msg "Stopping $PROGRAM..."
 92  $TCPD -pid=$PIDFILE -stop || log_end_msg 1
 93  log_end_msg 0
 94    ;;
 95restart | force-reload)
 96  $0 stop
 97  $0 start
 98    ;;
 99*)
100  log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
101  exit 1
102  ;;
103esac
104
105exit 0