PageRenderTime 180ms CodeModel.GetById 172ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/rc2.d/S20courier-imap-ssl

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