summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-misc/stunnel/files/stunnel.initd-start-stop-daemon')
-rw-r--r--net-misc/stunnel/files/stunnel.initd-start-stop-daemon39
1 files changed, 39 insertions, 0 deletions
diff --git a/net-misc/stunnel/files/stunnel.initd-start-stop-daemon b/net-misc/stunnel/files/stunnel.initd-start-stop-daemon
new file mode 100644
index 000000000000..051f7022aab3
--- /dev/null
+++ b/net-misc/stunnel/files/stunnel.initd-start-stop-daemon
@@ -0,0 +1,39 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/stunnel/files/stunnel.initd-start-stop-daemon,v 1.1 2012/05/13 21:08:13 ramereth Exp $
+
+SERVICENAME=${SVCNAME#*.}
+SERVICENAME=${SERVICENAME:-stunnel}
+STUNNEL_CONFIGFILE=${STUNNEL_CONFIGFILE:-/etc/stunnel/${SERVICENAME}.conf}
+
+depend() {
+ need net
+ before logger
+}
+
+get_config() {
+ if [ ! -e ${STUNNEL_CONFIGFILE} ] ; then
+ eerror "You need to create ${STUNNEL_CONFIGFILE} first."
+ return 1
+ fi
+ CHROOT=$(grep "^chroot" ${STUNNEL_CONFIGFILE} | sed "s;.*= *;;")
+ [ -n "${CHROOT}" ] && CHROOT="--chroot ${CHROOT}"
+ PIDFILE=$(grep "^pid" ${STUNNEL_CONFIGFILE} | sed "s;.*= *;;")
+ PIDFILE=${PIDFILE:-/var/run/stunnel/${SERVICENAME}.pid}
+}
+
+start() {
+ get_config || return 1
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --pidfile "${PIDFILE}" ${CHROOT} \
+ --exec /usr/bin/stunnel -- ${STUNNEL_CONFIGFILE} ${STUNNEL_OPTIONS}
+ eend $? "Failed to start ${SVCNAME}"
+}
+
+stop() {
+ get_config || return 1
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
+ eend $? "Failed to stop ${SVCNAME}"
+}