PageRenderTime 18072ms CodeModel.GetById 18066ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/rc2.d/S20courier-pop-ssl

http://github.com/brinkman83/bashrc
Shell | 118 lines | 91 code | 15 blank | 12 comment | 11 complexity | 8e3888c74d4a9b09380a155c9412dc9e MD5 | raw file
  1#! /bin/sh -e
  2### BEGIN INIT INFO
  3# Short-Description: Courier POP3-SSL server
  4# Provides:          courier-pop-ssl
  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-ssl is an POP3 Mail Delivery Agent with SSL support.
 10### END INIT INFO
 11
 12prefix="/usr"
 13exec_prefix=${prefix}
 14sysconfdir="/etc/courier"
 15sbindir="${exec_prefix}/sbin"
 16bindir="${exec_prefix}/bin"
 17libexecdir="${prefix}/lib/courier"
 18run_dir="/var/run/courier"
 19calendar_dir="/var/run/courier/calendar"
 20TCPD=${sbindir}/couriertcpd
 21DAEMONPROG=${sbindir}/pop3d
 22DAEMON=pop3d-ssl
 23PROGRAM="Courier POP3-SSL server"
 24
 25test -f $DAEMONPROG || 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
 40if ! [ -x $TCPD ]; then
 41  log_failure_msg "ERR: $TCPD missing"
 42  exit 1
 43fi
 44
 45if ! [ -f ${sysconfdir}/pop3d ]; then
 46  log_failure_msg "ERR: config file missing"
 47  exit 1
 48fi
 49if ! [ -f ${sysconfdir}/pop3d-ssl ]; then
 50  log_failure_msg "ERR: config file missing"
 51  exit 1
 52fi
 53
 54# read/set defaults
 55if [ -f /etc/default/courier ]; then
 56	. /etc/default/courier
 57fi
 58# ensure that maildirpath is set
 59if [ -z "$MAILDIRPATH" ]; then
 60	MAILDIRPATH=Maildir
 61fi
 62
 63. ${sysconfdir}/pop3d
 64. ${sysconfdir}/pop3d-ssl
 65
 66if ! [ -x $COURIERTLS ]; then
 67  log_failure_msg "ERR: $COURIERTLS missing"
 68  exit 1
 69fi
 70
 71START=no
 72case "$POP3DSSLSTART" in
 73	[yY]*)START=yes;;
 74esac
 75
 76if [ "$START" = "no" ]; then
 77	exit 0
 78fi
 79
 80case "$1" in
 81start)
 82    log_begin_msg "Starting $PROGRAM..."
 83
 84    /usr/bin/env - PATH="$PATH" SHELL="$SHELL" \
 85		/bin/sh -c " . ${sysconfdir}/pop3d ; \
 86		. ${sysconfdir}/pop3d-ssl ; \
 87		POP3_TLS=1 ; export POP3_TLS ; \
 88		POP3_STARTTLS=NO; export POP3_STARTTLS; \
 89		POP3_TLS_REQUIRED=0; export POP3_TLS_REQUIRED; \
 90		`sed -n '/^#/d;/=/p' <${sysconfdir}/pop3d | \
 91			sed 's/=.*//;s/^/export /;s/$/;/'`
 92		`sed -n '/^#/d;/=/p' <${sysconfdir}/pop3d-ssl | \
 93			sed 's/=.*//;s/^/export /;s/$/;/'`
 94	  PROXY_HOSTNAME=$PROXY_HOSTNAME; \
 95      /usr/sbin/courierlogger -pid=$SSLPIDFILE -start $SSLLOGGEROPTS \
 96	  $TCPD -address=$SSLADDRESS \
 97      -maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
 98      $TCPDOPTS \
 99	  $SSLPORT $COURIERTLS -server -tcpd \
100      ${libexecdir}/courier/courierpop3login \
101      ${libexecdir}/courier/courierpop3d $MAILDIRPATH"
102    log_end_msg 0
103	;;
104stop)
105  log_begin_msg "Stopping $PROGRAM..."
106  /usr/sbin/courierlogger -pid=$SSLPIDFILE -stop || log_end_msg 1
107  log_end_msg 0
108	;;
109restart | force-reload)
110  $0 stop
111  $0 start
112	;;
113*)
114  log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
115  exit 1
116  ;;
117esac
118exit 0