Hey!

"birdc configure" (or any command in fact) exits with 0 on error. This
is a bit annoying as when using "systemctl reload bird", we get no
notification there is an error.

Looking at the source code, it seems there is no easy way to hack around
that. Commands do not report an error code and messages printed are not
tagged as errors.

Here is a small workaround for systemd:

>From 5cbc487c4d54033c688258a5361377f72f53c264 Mon Sep 17 00:00:00 2001
From: Vincent Bernat <vinc...@bernat.ch>
Date: Thu, 10 Mar 2022 19:36:53 +0100
Subject: [PATCH] Pkg: check configuration before reloading with systemd

Also, update the RPM version to use "birdc configure" instead of "kill
-HUP".
---
 distro/pkg/deb/bird2.bird.service | 1 +
 distro/pkg/rpm/bird.service       | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/distro/pkg/deb/bird2.bird.service b/distro/pkg/deb/bird2.bird.service
index 37e75fb41c6a..ae48f7f46cfa 100644
--- a/distro/pkg/deb/bird2.bird.service
+++ b/distro/pkg/deb/bird2.bird.service
@@ -6,6 +6,7 @@ After=network.target
 EnvironmentFile=/etc/bird/envvars
 ExecStartPre=/usr/lib/bird/prepare-environment
 ExecStartPre=/usr/sbin/bird -p
+ExecReload=/usr/sbin/bird -p
 ExecReload=/usr/sbin/birdc configure
 ExecStart=/usr/sbin/bird -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP $BIRD_ARGS
 Restart=on-abort
diff --git a/distro/pkg/rpm/bird.service b/distro/pkg/rpm/bird.service
index fa203c781905..aa6e12dc5489 100644
--- a/distro/pkg/rpm/bird.service
+++ b/distro/pkg/rpm/bird.service
@@ -5,8 +5,10 @@ After=network.target
 
 [Service]
 Type=simple
+ExecStartPre=/usr/sbin/bird -p
 ExecStart=/usr/sbin/bird -f -u bird -g bird
-ExecReload=/bin/kill -HUP $MAINPID
+ExecReload=/usr/sbin/bird -p
+ExecReload=/usr/sbin/birdc configure
 Restart=on-failure
 
 [Install]
-- 
2.35.1

-- 
Keep it simple to make it faster.
            - The Elements of Programming Style (Kernighan & Plauger)

Reply via email to