diff options
author | 2009-08-23 01:34:36 +0000 | |
---|---|---|
committer | 2009-08-23 01:34:36 +0000 | |
commit | 20ef76400f7144529f0173442c6fb56560fe31b0 (patch) | |
tree | 571e7574ea8ac476af88f8bbd75c75b6261bbc35 /net-misc/stunnel/files | |
parent | remove unused patches (diff) | |
download | gentoo-2-20ef76400f7144529f0173442c6fb56560fe31b0.tar.gz gentoo-2-20ef76400f7144529f0173442c6fb56560fe31b0.tar.bz2 gentoo-2-20ef76400f7144529f0173442c6fb56560fe31b0.zip |
Fix init script for #107484 & #102179 (chroot & multiple instance support)
(Portage version: 2.1.6.13/cvs/Linux x86_64)
Diffstat (limited to 'net-misc/stunnel/files')
-rw-r--r-- | net-misc/stunnel/files/stunnel.initd | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/net-misc/stunnel/files/stunnel.initd b/net-misc/stunnel/files/stunnel.initd new file mode 100644 index 000000000000..8a31e3db858a --- /dev/null +++ b/net-misc/stunnel/files/stunnel.initd @@ -0,0 +1,68 @@ +#!/sbin/runscript +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Default pidfile location +DEFAULT_PIDFILE="/var/run/stunnel/stunnel.pid" +FILES="/etc/stunnel/*.conf" +DAEMON="/usr/sbin/stunnel" + +depend() { + need net + before logger +} + +get_pids() { + local file=${1} + if test -f ${file} ; then + CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;") + PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;") + if [ "${PIDFILE}" == "" ] ; then + PIDFILE="${DEFAULT_PIDFILE}" + fi + if test -f ${CHROOT}/${PIDFILE} ; then + cat ${CHROOT}/${PIDFILE} + fi + fi +} + +start() { + rm -rf /var/run/stunnel/*.pid + ebegin "Starting stunnel" + for file in ${FILES} ; do + if test -f "${file}" ; then + ARGS="${file} ${STUNNEL_OPTIONS}" + PROCLIST="$(get_pids ${file})" + CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;") + PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;") + if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then + ewarn " already running: ${file} " + elif ${DAEMON} ${ARGS} ; then + if test -f ${CHROOT}/${PIDFILE} ; then + einfo " ${file}" + else + eerror " error starting: ${file}" + fi + fi + fi + done + eend $? +} + +stop() { + ebegin "Stopping stunnel" + for file in ${FILES} ; do + PROCLIST=$(get_pids ${file}) + if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then + kill ${PROCLIST} + einfo " ${file} " + fi + done + eend $? +} + +restart() { + stop + sleep 1 + start +} |