PageRenderTime 102ms CodeModel.GetById 97ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/rc1.d/K20courier-imap

http://github.com/brinkman83/bashrc
#! | 114 lines | 101 code | 13 blank | 0 comment | 0 complexity | c3d611bda866e4316a91fa6819cfa365 MD5 | raw file
  1#! /bin/bash -e
  2### BEGIN INIT INFO
  3# Short-Description: Courier IMAP server
  4# Provides:          courier-imap
  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.
 10### END INIT INFO
 11prefix="/usr"
 12exec_prefix=${prefix}
 13sysconfdir="/etc/courier"
 14bindir="${exec_prefix}/bin"
 15sbindir="${exec_prefix}/sbin"
 16libexecdir="${prefix}/lib/courier"
 17TCPD="${sbindir}/couriertcpd"
 18run_dir="/var/run/courier"
 19calendar_dir="/var/run/courier/calendar"
 20DAEMON="imapd"
 21PROGRAM="Courier IMAP server"
 22SSLCONFIG=
 23
 24. /lib/lsb/init-functions
 25
 26# first of all check if daemon is available
 27if ! [ -x "${bindir}/imapd" ]; then
 28	exit 0
 29fi
 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}/$DAEMON ]; then
 48  log_failure_msg "ERR: config file missing"
 49  exit 1
 50fi
 51
 52# read/set defaults
 53if [ -f /etc/default/courier ]; then
 54	. /etc/default/courier
 55fi
 56# ensure that maildirpath is set
 57if [ -z "$MAILDIRPATH" ]; then
 58	MAILDIRPATH=Maildir
 59fi
 60
 61if [ -f "${sysconfdir}/imapd-ssl" ]; then
 62	. "${sysconfdir}/imapd-ssl"
 63	SSLCONFIG=1
 64fi
 65. ${sysconfdir}/$DAEMON
 66
 67# ensure that umask is set
 68if [ -z "$IMAP_UMASK" ]; then
 69	IMAP_UMASK=022
 70fi
 71
 72START=no
 73case "$IMAPDSTART" in
 74	[yY]*)START=yes;;
 75esac
 76
 77case "$1" in
 78start)
 79  if [ "$START" = "yes" ]; then
 80    log_begin_msg "Starting $PROGRAM..."
 81
 82	umask $IMAP_UMASK
 83    ulimit -v $IMAP_ULIMITD
 84    /usr/bin/env - /bin/sh -c " set -a; \
 85		bindir=${bindir}; \
 86		. ${sysconfdir}/imapd; \
 87		if [ "$SSLCONFIG" ]; then . ${sysconfdir}/imapd-ssl; fi; \
 88		IMAP_STARTTLS=$IMAPDSTARTTLS ; export IMAP_STARTTLS ; \
 89		PROXY_HOSTNAME=$PROXY_HOSTNAME; 
 90		TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL ; \
 91		/usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \
 92		$TCPD -address=$ADDRESS \
 93			-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
 94			$TCPDOPTS \
 95			$PORT ${libexecdir}/courier/imaplogin \
 96				${bindir}/imapd $MAILDIRPATH"
 97    log_end_msg 0
 98  fi
 99	;;
100stop)
101  log_begin_msg "Stopping $PROGRAM..."
102  /usr/sbin/courierlogger -pid=$PIDFILE -stop || log_end_msg 1
103  log_end_msg 0
104	;;
105restart | force-reload)
106  $0 stop
107  $0 start
108	;;
109*)
110  log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
111  exit 1
112  ;;
113esac
114exit 0