/[gentoo-x86]/net-misc/stunnel/files/stunnel.initd
Gentoo

Contents of /net-misc/stunnel/files/stunnel.initd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Jun 21 00:46:41 2010 UTC (4 years ago) by ramereth
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +5 -0 lines
Version bump, stablize 4.29-r1 & 4.31-r1, ebuild clean up, add 0.5s delay in init script to resolve bug #308931
(Portage version: 2.1.8.3/cvs/Linux x86_64)

1 #!/sbin/runscript
2 # Copyright 1999-2009 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # Default pidfile location
6 DEFAULT_PIDFILE="/var/run/stunnel/stunnel.pid"
7 FILES="/etc/stunnel/*.conf"
8 DAEMON="/usr/sbin/stunnel"
9
10 depend() {
11 need net
12 before logger
13 }
14
15 get_pids() {
16 local file=${1}
17 if test -f ${file} ; then
18 CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;")
19 PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;")
20 if [ "${PIDFILE}" == "" ] ; then
21 PIDFILE="${DEFAULT_PIDFILE}"
22 fi
23 if test -f ${CHROOT}/${PIDFILE} ; then
24 cat ${CHROOT}/${PIDFILE}
25 fi
26 fi
27 }
28
29 start() {
30 rm -rf /var/run/stunnel/*.pid
31 ebegin "Starting stunnel"
32 for file in ${FILES} ; do
33 if test -f "${file}" ; then
34 ARGS="${file} ${STUNNEL_OPTIONS}"
35 PROCLIST="$(get_pids ${file})"
36 CHROOT=$(grep "^chroot" ${file} | sed "s;.*= *;;")
37 PIDFILE=$(grep "^pid" ${file} | sed "s;.*= *;;")
38 if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then
39 ewarn " already running: ${file} "
40 elif ${DAEMON} ${ARGS} ; then
41 if ! test -f ${CHROOT}/${PIDFILE} ; then
42 # give the daemon time to create the pid file
43 # See bug #308931 for more details
44 sleep 0.5s
45 fi
46 if test -f ${CHROOT}/${PIDFILE} ; then
47 einfo " ${file}"
48 else
49 eerror " error starting: ${file}"
50 fi
51 fi
52 fi
53 done
54 eend $?
55 }
56
57 stop() {
58 ebegin "Stopping stunnel"
59 for file in ${FILES} ; do
60 PROCLIST=$(get_pids ${file})
61 if [ "${PROCLIST}" ] && kill -0 ${PROCLIST} 2> /dev/null ; then
62 kill ${PROCLIST}
63 einfo " ${file} "
64 fi
65 done
66 eend $?
67 }
68
69 restart() {
70 svc_stop
71 sleep 1
72 svc_start
73 }

  ViewVC Help
Powered by ViewVC 1.1.20