diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2018-07-07 11:42:03 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2018-07-07 11:42:03 +0100 |
commit | f70601e0934acd62f6c5d06c5ede4cc607179514 (patch) | |
tree | 0b337390375de04b950fc4b45edc0f895a4701a4 /net-dialup/openl2tp/files/openl2tpd.initd | |
parent | b2be182d49eea46686b5cf2680d457df61e89dc4 (diff) |
gentoo resync : 07.07.2018
Diffstat (limited to 'net-dialup/openl2tp/files/openl2tpd.initd')
-rw-r--r-- | net-dialup/openl2tp/files/openl2tpd.initd | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/net-dialup/openl2tp/files/openl2tpd.initd b/net-dialup/openl2tp/files/openl2tpd.initd new file mode 100644 index 000000000000..b1d1511a5642 --- /dev/null +++ b/net-dialup/openl2tp/files/openl2tpd.initd @@ -0,0 +1,69 @@ +#!/sbin/openrc-run +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +userpc="yes" +retry_count="40" +retry_delay="0.5" + +bin=/usr/sbin/openl2tpd +pid=/var/run/openl2tpd.pid +[ -z "${OPENL2TPD_CONFIG_FILE}" ] && OPENL2TPD_CONFIG_FILE="/etc/openl2tpd.conf" + +depend() { + need net + [ "${userpc}" = "yes" ] && need portmap + use dns ipsec racoon +} + +check_module () { + if ! [ -f /proc/net/pppol2tp ]; then + ebegin "Loading l2tp module" + # try both new and old module names + modprobe l2tp_ppp 2>/dev/null || modprobe pppol2tp 2>/dev/null + eend $? + fi +} + +start() { + check_module + ebegin "Starting openl2tpd" + # if rpc is enabled do not read config file by daemon (has bugs), + # but read by l2tpconfig instead + if [ "${userpc}" = "yes" ]; then + conf="/dev/null" + else + conf="${OPENL2TPD_CONFIG_FILE}" + fi + + start-stop-daemon --start --quiet --exec ${bin} --pidfile ${pid} \ + -- -c "$conf" ${OPENL2TPDARGS} + + # it is possible to not to have config at all + if [ "${userpc}" = "yes" ] && [ -r "${OPENL2TPD_CONFIG_FILE}" ]; then + # on system startup it may take some time to load daemon + local i=0; + while [ $i -lt $retry_count ]; do + l2tpconfig config restore file="${OPENL2TPD_CONFIG_FILE}" >/dev/null 2>&1 + retcode=$? + [ ${retcode} = 0 ] && break + i=$((i+1)) + sleep $retry_delay + done + fi + eend $retcode +} + +stop() { + local rc + ebegin "Stopping openl2tpd" + start-stop-daemon --stop --quiet --exec ${bin} --pidfile ${pid} + rc=$? + + if [ ${RC_CMD} = "restart" ]; then + einfo "sleepinng for server to finilize connections" + sleep 2 + fi + + eend ${rc} +} |