aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testing/bird/APKBUILD2
-rw-r--r--testing/bird/bird.initd45
2 files changed, 36 insertions, 11 deletions
diff --git a/testing/bird/APKBUILD b/testing/bird/APKBUILD
index 74e39b29dc..57b5d5c822 100644
--- a/testing/bird/APKBUILD
+++ b/testing/bird/APKBUILD
@@ -35,4 +35,4 @@ package() {
sha512sums="22aa676e171cf5ddf6dedbf0dfe9bb36a959efdf9cb278b7e969d5b08b06fe483e3b30ef40c1f9980387ed6ac6ee6626f3d85704925256c22dae91fa7d23267d bird-2.0.6.tar.gz
e0a9bab1bb84ab4efbf51c4c015bf35196d146560f737979d3a17c44dc2397d9578e61a3bba0c58f3cdbb108074f17288bf536db5d8d4dce87c91f1be3dc6282 bird-make-test-bsprintf.patch
-59245af3fd514421d0babcefed556597022a36d14615d596bb5c08c7dd0a6ed4519928e35a0b7ff14fe27ecfa50fa8011283c92bfc9b8355b15b3263df189d5d bird.initd"
+da2fd6eaf5e468eed1054c23299ae899d5b1152c94a500db2242c63cdd543a32218e45373470ff367d5736022ced18e6a427f6b98e69a34ae2d3bf811550d828 bird.initd"
diff --git a/testing/bird/bird.initd b/testing/bird/bird.initd
index fb29c19bb0..94b953974b 100644
--- a/testing/bird/bird.initd
+++ b/testing/bird/bird.initd
@@ -1,12 +1,20 @@
#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Copyright 2019 Alarig Le Lay <alarig@grifon.fr>
+# Distributed under the terms of the GNU General Public License v2
extra_started_commands="reload"
-name=bird
-command=/usr/sbin/$name
+pidfile="/run/${RC_SVCNAME}.pid"
+command="/usr/sbin/${RC_SVCNAME}"
+retry=15
-sock="/var/run/$name.ctl"
-command_args="-c /etc/${name}.conf -s $sock"
+CONF_FILE="/etc/${RC_SVCNAME}.conf"
+SOCK="/run/${RC_SVCNAME}.ctl"
+
+client_args="-s ${SOCK}"
+command_args="${client_args} -R -c ${CONF_FILE} -P ${pidfile}"
+client_args="${client_args} -r"
depend() {
need net
@@ -14,14 +22,31 @@ depend() {
after firewall
}
-start_pre() {
- [ -f "/etc/$name.conf" ] && return 0
- eerror "Please create /etc/$name.conf"
- return 1
+check_run() {
+ BIRD_CHECK_CONF="birdc ${client_args} configure check \"${CONF_FILE}\""
+ # Check if the bird parser returns what we want
+ # We can’t use $? because it’s always 0 if the sock works
+ STATE=$(${BIRD_CHECK_CONF} | grep 'Configuration OK')
+
+ if [ -n "${STATE}" ]; then
+ return 0
+ else
+ # We remove the first three lines (garbage informations), the
+ # errors begin after that
+ eerror "$(${BIRD_CHECK_CONF} | sed '1,3d')"
+ return 1
+ fi
}
reload() {
- ebegin "Reloading $name"
- killall -HUP $command
+ check_run || return 1
+ ebegin "Reloading BIRD"
+ start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
+
+stop_pre() {
+ if [ "${RC_CMD}" = "restart" ] ; then
+ check_run || return 1
+ fi
+}