Gentoo Archives: gentoo-commits

From: "Lance Albertson (ramereth)" <ramereth@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-misc/stunnel/files: stunnel.initd
Date: Sun, 23 Aug 2009 01:34:39
Message-Id: E1Mf1ye-0007Jg-FL@stork.gentoo.org
1 ramereth 09/08/23 01:34:36
2
3 Added: stunnel.initd
4 Log:
5 Fix init script for #107484 & #102179 (chroot & multiple instance support)
6 (Portage version: 2.1.6.13/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 net-misc/stunnel/files/stunnel.initd
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/stunnel/files/stunnel.initd?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/stunnel/files/stunnel.initd?rev=1.1&content-type=text/plain
13
14 Index: stunnel.initd
15 ===================================================================
16 #!/sbin/runscript
17 # Copyright 1999-2009 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19
20 # Default pidfile location
21 DEFAULT_PIDFILE="/var/run/stunnel/stunnel.pid"
22 FILES="/etc/stunnel/*.conf"
23 DAEMON="/usr/sbin/stunnel"
24
25 depend() {
26 need net
27 before logger
28 }
29
30 get_pids() {
31 local file=${1}
32 if test -f ${file} ; then
33 CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;")
34 PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;")
35 if [ "${PIDFILE}" == "" ] ; then
36 PIDFILE="${DEFAULT_PIDFILE}"
37 fi
38 if test -f ${CHROOT}/${PIDFILE} ; then
39 cat ${CHROOT}/${PIDFILE}
40 fi
41 fi
42 }
43
44 start() {
45 rm -rf /var/run/stunnel/*.pid
46 ebegin "Starting stunnel"
47 for file in ${FILES} ; do
48 if test -f "${file}" ; then
49 ARGS="${file} ${STUNNEL_OPTIONS}"
50 PROCLIST="$(get_pids ${file})"
51 CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;")
52 PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;")
53 if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then
54 ewarn " already running: ${file} "
55 elif ${DAEMON} ${ARGS} ; then
56 if test -f ${CHROOT}/${PIDFILE} ; then
57 einfo " ${file}"
58 else
59 eerror " error starting: ${file}"
60 fi
61 fi
62 fi
63 done
64 eend $?
65 }
66
67 stop() {
68 ebegin "Stopping stunnel"
69 for file in ${FILES} ; do
70 PROCLIST=$(get_pids ${file})
71 if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then
72 kill ${PROCLIST}
73 einfo " ${file} "
74 fi
75 done
76 eend $?
77 }
78
79 restart() {
80 stop
81 sleep 1
82 start
83 }