From 2d306ec39259ad6520dc12a618a016fd9561c9f9 Mon Sep 17 00:00:00 2001 From: alarig Date: Tue, 5 Mar 2019 11:45:47 +0100 Subject: [PATCH] First try for a new initd script --- net-misc/bird/bird-2.0.4.ebuild | 2 +- net-misc/bird/files/initd-bird-2 | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100755 net-misc/bird/files/initd-bird-2 diff --git a/net-misc/bird/bird-2.0.4.ebuild b/net-misc/bird/bird-2.0.4.ebuild index 298936a..152c1ad 100644 --- a/net-misc/bird/bird-2.0.4.ebuild +++ b/net-misc/bird/bird-2.0.4.ebuild @@ -31,6 +31,6 @@ src_install() { fi dobin birdcl dosbin bird - newinitd "${FILESDIR}/initd-v4-${PN}-1.3.8" bird + newinitd "${FILESDIR}/initd-${PN}-2" bird dodoc doc/bird.conf.example } diff --git a/net-misc/bird/files/initd-bird-2 b/net-misc/bird/files/initd-bird-2 new file mode 100755 index 0000000..036e49f --- /dev/null +++ b/net-misc/bird/files/initd-bird-2 @@ -0,0 +1,56 @@ +#!/sbin/openrc-run +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_started_commands="reload" + +pidfile="/var/run/${RC_SVCNAME}.pid" +CONF_FILE="/etc/${RC_SVCNAME}.conf" +SOCK="/var/run/${RC_SVCNAME}.ctl" + +command="/usr/sbin/${RC_SVCNAME}" +command_args="-c ${CONF_FILE} -s ${SOCK} -P ${pidfile}" + +depend() { + need net + use logger +} + +checkconfig() { + if [ ! -f "CONF_FILE" ]; then + eerror "Please create ${CONF_FILE}" + return 1 + fi + return 0 +} + +check_run() { + STATE=$(birdc -s /var/run/bird.ctl 'configure check' | \ + grep 'Configuration OK') + + if [ -n "${STATE}" ]; then + return 0 + else + eerror "$(birdc -s /var/run/bird.ctl 'configure check' | \ + sed '1d;2d')" + return 1 + fi +} + +reload() { + check_run || return 1 + ebegin "Reloading BIRD" + start-stop-daemon --signal HUP --exec ${command} + eend $? +} + +stop_pre() { + if [ "${RC_CMD}" = "restart" ] ; then + check_run || return 1 + fi +} + +stop() { + ebegin "Stopping BIRD" + start-stop-daemon --stop --exec ${command} --retry 15 +}