diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2017-05-04 13:22:42 +0200 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2017-05-04 13:23:43 +0200 |
commit | 682038d993d371b9cc6f80e61952c3ef125ece41 (patch) | |
tree | 97facb6de0926efd9bd804e3b88cb12ddd1c44e6 /testing/tinc-pre/tinc-pre.initd | |
parent | 8aee06c26899a70bd8c2597cca85a46e311c9fac (diff) |
testing/tinc-pre: new aport
Diffstat (limited to 'testing/tinc-pre/tinc-pre.initd')
-rw-r--r-- | testing/tinc-pre/tinc-pre.initd | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/tinc-pre/tinc-pre.initd b/testing/tinc-pre/tinc-pre.initd new file mode 100644 index 00000000000..55728bec2c7 --- /dev/null +++ b/testing/tinc-pre/tinc-pre.initd @@ -0,0 +1,78 @@ +#!/sbin/openrc-run +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_started_commands="reload" + +NETS="/etc/conf.d/tinc.networks" +DAEMON="/usr/sbin/tincd" + +depend() { + use logger dns + need net +} + +checkconfig() { + if [ "${RC_SVCNAME}" = "tincd" ] ; then + ALL_NETNAME="$(awk '/^ *NETWORK:/ { print $2 }' "${NETS}")" + else + ALL_NETNAME="${RC_SVCNAME#*.}" + fi + # warn this if still not found + if [ -z "${ALL_NETNAME}" ] ; then + eerror "No VPN networks configured in ${NETS}" + return 1 + fi + return 0 +} + +start() { + ebegin "Starting tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + CONFIG="/etc/tinc/${NETNAME}/tinc.conf" + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ ! -f "${CONFIG}" ]; then + eerror "Cannot start network ${NETNAME}." + eerror "Please set up ${CONFIG} !" + else + 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}" --debug="${DEBUG_LEVEL}" ${EXTRA_OPTS} + eend $? + fi + done +} + +stop() { + ebegin "Stopping tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Stopping tinc network ${NETNAME}" + start-stop-daemon --stop --pidfile "${PIDFILE}" + eend $? + fi + done +} + +reload() { + ebegin "Reloading configuration for tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Reloading tinc network ${NETNAME}" + start-stop-daemon --signal HUP --pidfile ${PIDFILE} + eend $? + fi + done +} |