#!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /etc/init.d/RCS/stunnel,v 1.2 2006/06/22 02:13:29 root Exp root $ depend() { need net } checkconfig() { STUNNEL_INSTANCE=${SVCNAME##*.} if [[ "${SVCNAME}" != "stunnel" ]]; then STUNNEL_CONF=/etc/stunnel/stunnel.${STUNNEL_INSTANCE}.conf else STUNNEL_CONF=/etc/stunnel/stunnel.conf fi if [ ! -e ${STUNNEL_CONF} ]; then eerror "You will need an '${STUNNEL_CONF}' first" eerror "See the stunnel manpage" return 1 fi # Extract PID file from stunnel.conf STUNNEL_PIDFILE=$(egrep '^pid[[:space:]]*=[[:space:]]*' ${STUNNEL_CONF} 2>/dev/null | sed -e 's:^pid\s*=\s*\(.*\)$:\1:') # Check if PID file is sane if [[ "${SVCNAME}" == "stunnel" && "${STUNNEL_PIDFILE}" != /var/run/stunnel/stunnel.pid ]]; then eerror "Your '${STUNNEL_CONF}' does not contain the required pid file setting!" eerror "Please set 'pid = /var/run/stunnel/stunnel.pid'" return 1 elif [[ "${SVCNAME}" != "stunnel" && "${STUNNEL_PIDFILE}" != /var/run/stunnel/stunnel.${STUNNEL_INSTANCE}.pid ]]; then eerror "Your '${STUNNEL_CONF}' does not contain the required pid file setting!" eerror "Please set 'pid = /var/run/stunnel/stunnel.${STUNNEL_INSTANCE}.pid'" return 1 fi } start() { checkconfig || return 1 ebegin "Starting ${SVCNAME}" start-stop-daemon --start --pidfile ${STUNNEL_PIDFILE} --quiet --exec /usr/sbin/stunnel -- ${STUNNEL_CONF} eend $? } stop() { checkconfig || return 1 ebegin "Stopping ${SVCNAME}" start-stop-daemon --stop --quiet --pidfile ${STUNNEL_PIDFILE} eend $? }