aboutsummaryrefslogtreecommitdiffstats
path: root/main/tinc/tincd.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-06-09 08:53:50 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-06-09 08:53:50 +0000
commit56db87515d46cee8adca0cadb34d3001951c203e (patch)
tree71cf7c965910dd671b700e9f645d1f59d4151a18 /main/tinc/tincd.initd
parent14b0a8983c5199a8359ab6a1af9e79817c13a6a3 (diff)
downloadaports-56db87515d46cee8adca0cadb34d3001951c203e.tar.bz2
aports-56db87515d46cee8adca0cadb34d3001951c203e.tar.xz
main/tinc: sync init.d scripts with gentoo
Diffstat (limited to 'main/tinc/tincd.initd')
-rw-r--r--main/tinc/tincd.initd55
1 files changed, 30 insertions, 25 deletions
diff --git a/main/tinc/tincd.initd b/main/tinc/tincd.initd
index c302f4fe0c..b26185eae4 100644
--- a/main/tinc/tincd.initd
+++ b/main/tinc/tincd.initd
@@ -1,10 +1,12 @@
#!/sbin/runscript
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/tinc/files/tincd,v 1.5 2008/04/01 14:08:45 dragonheart Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/tinc/files/tincd,v 1.9 2013/09/01 12:22:46 blueness Exp $
extra_started_commands="reload"
-daemon=/usr/sbin/tincd
+
+NETS="/etc/conf.d/tinc.networks"
+DAEMON="/usr/sbin/tincd"
depend() {
use logger dns
@@ -12,9 +14,8 @@ depend() {
}
checkconfig() {
- if ! grep -q '^ *NETWORK:' /etc/conf.d/tinc.networks
- then
- eerror "No VPN networks configured in /etc/conf.d/tinc.networks"
+ if ! grep -q '^ *NETWORK:' "${NETS}" ; then
+ eerror "No VPN networks configured in ${NETS}"
return 1
fi
}
@@ -22,15 +23,21 @@ checkconfig() {
start() {
checkconfig || return 1
ebegin "Starting tinc VPN networks"
- eend 0
- awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
+ awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read NETNAME
do
- if [ ! -f /etc/tinc/"$TINCNET"/tinc.conf ]
- then
- eerror "Cannot start network $TINCNET, /etc/tinc/$TINCNET/tinc.conf does not exist !"
+ CONFIG="/etc/tinc/${NETNAME}/tinc.conf"
+ PIDFILE="/var/run/tinc.${NETNAME}.pid"
+ if [ ! -f "${CONFIG}" ]; then
+ eerror "Cannot start network ${NETNAME}."
+ eerror "Please set up ${CONFIG} !"
else
- ebegin "Starting tinc network $TINCNET"
- $daemon --net="$TINCNET" --logfile=/var/log/tinc.$TINCNET.log --pidfile=/var/run/tinc.$TINCNET.pid
+ ebegin "Starting tinc network ${NETNAME}"
+ if [ "${SYSLOG}" == "yes" ]; then
+ LOG=""
+ else
+ LOG="--logfile=/var/log/tinc.${NETNAME}.log"
+ fi
+ start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}" -- --net="${NETNAME}" ${LOG} --pidfile "${PIDFILE}"
eend $?
fi
done
@@ -38,13 +45,12 @@ start() {
stop() {
ebegin "Stopping tinc VPN networks"
- eend 0
- awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
+ awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read NETNAME
do
- if [ -f /var/run/tinc."$TINCNET".pid ]
- then
- ebegin "Stopping tinc network $TINCNET"
- start-stop-daemon --stop --quiet --pidfile=/var/run/tinc.$TINCNET.pid --exec ${daemon}
+ PIDFILE="/var/run/tinc.${NETNAME}.pid"
+ if [ -f "${PIDFILE}" ]; then
+ ebegin "Stopping tinc network ${NETNAME}"
+ start-stop-daemon --stop --pidfile "${PIDFILE}"
eend $?
fi
done
@@ -52,13 +58,12 @@ stop() {
reload() {
ebegin "Reloading configuration for tinc VPN networks"
- eend 0
- awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
+ awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read NETNAME
do
- if [ -f /var/run/tinc."$TINCNET".pid ]
- then
- ebegin "Reloading tinc network $TINCNET"
- kill -1 $(awk '{ print $1 }' /var/run/tinc."$TINCNET".pid)
+ PIDFILE="/var/run/tinc.${NETNAME}.pid"
+ if [ -f "${PIDFILE}" ]; then
+ ebegin "Reloading tinc network ${NETNAME}"
+ start-stop-daemon --signal HUP --pidfile ${PIDFILE}
eend $?
fi
done