From 26a952aa6c179831ec3de30fe58c8c3cbf49d9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Wennerstr=C3=B6m?= Date: Tue, 5 Mar 2019 20:30:06 +0100 Subject: [PATCH 1/3] contrib/openrc: add init file for OpenRC --- contrib/openrc/yggdrasil | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 contrib/openrc/yggdrasil diff --git a/contrib/openrc/yggdrasil b/contrib/openrc/yggdrasil new file mode 100755 index 0000000..fa819ed --- /dev/null +++ b/contrib/openrc/yggdrasil @@ -0,0 +1,49 @@ +#!/sbin/openrc-run + +description="An experiment in scalable routing as an encrypted IPv6 overlay network." + +CONFFILE="/etc/yggdrasil.conf" +pidfile="/run/${RC_SVCNAME}.pid" + +command="/usr/bin/yggdrasil" + +depend() { + use net dns logger +} + +start_pre() { + if [ ! -f "${CONFFILE}" ]; then + ebegin "Generating new configuration file into ${CONFFILE}" + if ! eval ${command} -genconf > ${CONFFILE}; then + eerror "Failed to generate configuration file" + exit 1 + fi + fi + + if [ ! -e /dev/net/tun ]; then + ebegin "Inserting TUN module" + + if ! modprobe tun; then + eerror "Failed to insert TUN kernel module" + exit 1 + fi + fi +} + +start() { + ebegin "Starting Yggdrasil" + start-stop-daemon --start --quiet \ + --pidfile "${pidfile}" \ + --make-pidfile \ + --background \ + --stdout /var/log/yggdrasil.stdout.log \ + --stderr /var/log/yggdrasil.stderr.log \ + --exec "${command}" -- -useconf < "${CONFFILE}" + eend $? +} + +stop() { + ebegin "Stopping Yggdrasil" + start-stop-daemon --stop --pidfile "${pidfile}" --exec "${command}" + eend $? +} From 1097c1c0c964ef1e9df95fd3a3321ef46be93485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Wennerstr=C3=B6m?= Date: Tue, 5 Mar 2019 20:50:24 +0100 Subject: [PATCH 2/3] contrib/openrc: add reload command --- contrib/openrc/yggdrasil | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/contrib/openrc/yggdrasil b/contrib/openrc/yggdrasil index fa819ed..3c8b09b 100755 --- a/contrib/openrc/yggdrasil +++ b/contrib/openrc/yggdrasil @@ -6,6 +6,7 @@ CONFFILE="/etc/yggdrasil.conf" pidfile="/run/${RC_SVCNAME}.pid" command="/usr/bin/yggdrasil" +extra_started_commands="reload" depend() { use net dns logger @@ -31,19 +32,25 @@ start_pre() { } start() { - ebegin "Starting Yggdrasil" + ebegin "Starting ${RC_SVCNAME}" start-stop-daemon --start --quiet \ --pidfile "${pidfile}" \ --make-pidfile \ --background \ --stdout /var/log/yggdrasil.stdout.log \ --stderr /var/log/yggdrasil.stderr.log \ - --exec "${command}" -- -useconf < "${CONFFILE}" + --exec "${command}" -- -useconffile "${CONFFILE}" + eend $? +} + +reload() { + ebegin "Reloading ${RC_SVCNAME}" + start-stop-daemon --signal HUP --pidfile "${pidfile}" eend $? } stop() { - ebegin "Stopping Yggdrasil" + ebegin "Stopping ${RC_SVCNAME}" start-stop-daemon --stop --pidfile "${pidfile}" --exec "${command}" eend $? } From 76dd1f6345ac2a151d4110d2c35625db5bb1e81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Wennerstr=C3=B6m?= Date: Tue, 5 Mar 2019 22:27:51 +0100 Subject: [PATCH 3/3] contrib/openrc: I like symmetry --- contrib/openrc/yggdrasil | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/openrc/yggdrasil b/contrib/openrc/yggdrasil index 3c8b09b..4a2e0a1 100755 --- a/contrib/openrc/yggdrasil +++ b/contrib/openrc/yggdrasil @@ -23,7 +23,6 @@ start_pre() { if [ ! -e /dev/net/tun ]; then ebegin "Inserting TUN module" - if ! modprobe tun; then eerror "Failed to insert TUN kernel module" exit 1