* [gentoo-user] Question about bird init script
@ 2019-03-04 10:33 Alarig Le Lay
2019-03-04 14:05 ` Michael Orlitzky
0 siblings, 1 reply; 8+ messages in thread
From: Alarig Le Lay @ 2019-03-04 10:33 UTC (permalink / raw
To: gentoo-user
Hi again,
On another box, I’m trying to update to bird 2.0.4. I just copied the
ebuild and changed the version. If you want to have a look, it’s here:
https://git.grifon.fr/alarig/SwordArMor-gentoo-overlay/src/branch/master/net-misc/bird
It compiles well, but I have a weird behaviour on the service if I want
to stop it.
judicael-ovpn2 ~ # rc-service bird stop
* Stopping BIRD ...
* start-stop-daemon: 1 process refused to stop
* Failed to stop BIRD [ !! ]
* ERROR: bird failed to stop
But the process is actually killed and the service marked as crashed.
judicael-ovpn2 ~ # ps aux | grep bird
root 16679 0.0 0.1 10860 2152 pts/1 R+ 10:48 0:00 grep --colour=auto bird
judicael-ovpn2 ~ # rc-service bird status
* status: crashed
Otherwise, if I restart it, it works well.
judicael-ovpn2 ~ # rc-service bird zap
* Manually resetting bird to stopped state
judicael-ovpn2 ~ # rc-service bird restart
* Starting BIRD ... [ ok ]
judicael-ovpn2 ~ # ps aux | grep bird
root 16951 50.1 1.7 40304 35128 ? Rs 10:49 0:03 /usr/sbin/bird -c /etc/bird.conf -s /var/run/bird.ctl
root 17063 0.0 0.1 10860 2168 pts/1 S+ 10:49 0:00 grep --colour=auto bird
judicael-ovpn2 ~ # birdc 'sh pr'
BIRD 2.0.4 ready.
Name Proto Table State Since Info
device1 Device --- up 10:49:03.725
direct1 Direct --- up 10:49:03.725
kernel_ipv4 Kernel master4 up 10:49:03.725
kernel_ipv6 Kernel master6 up 10:49:03.725
ibgp_nominoe_ipv4 BGP --- up 10:49:05.942 Established
ibgp_nominoe_ipv6 BGP --- up 10:49:05.942 Established
ibgp_budic_ipv4 BGP --- up 10:49:07.189 Established
ibgp_budic_ipv6 BGP --- up 10:49:07.656 Established
ospf_ipv4 OSPF master4 up 10:49:03.725 Running
ospf_ipv6 OSPF master6 up 10:49:03.725 Running
I looked at the init script (in the files dir of the ebuild), but I
didn’t see what could fail.
Thanks,
--
Alarig
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-04 10:33 [gentoo-user] Question about bird init script Alarig Le Lay
@ 2019-03-04 14:05 ` Michael Orlitzky
2019-03-05 11:03 ` Alarig Le Lay
0 siblings, 1 reply; 8+ messages in thread
From: Michael Orlitzky @ 2019-03-04 14:05 UTC (permalink / raw
To: gentoo-user
On 3/4/19 5:33 AM, Alarig Le Lay wrote:
> Hi again,
>
> On another box, I’m trying to update to bird 2.0.4. I just copied the
> ebuild and changed the version. If you want to have a look, it’s here:
> https://git.grifon.fr/alarig/SwordArMor-gentoo-overlay/src/branch/master/net-misc/bird
>
> It compiles well, but I have a weird behaviour on the service if I want
> to stop it.
I know this isn't the answer you want, but before you waste any time
debugging, you should rewrite that ugly-ass service script to meet
modern standards:
https://github.com/OpenRC/openrc/blob/master/service-script-guide.md
I'm pretty sure you can delete 90% of it, and make it work better in the
process. Then, if start/stop/reload still don't work, it will be
worthwhile to figure out why.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-04 14:05 ` Michael Orlitzky
@ 2019-03-05 11:03 ` Alarig Le Lay
2019-03-05 15:01 ` Michael Orlitzky
0 siblings, 1 reply; 8+ messages in thread
From: Alarig Le Lay @ 2019-03-05 11:03 UTC (permalink / raw
To: gentoo-user
Okay, I tried to write another script:
https://git.grifon.fr/alarig/SwordArMor-gentoo-overlay/src/branch/master/net-misc/bird/files/initd-bird-2
I deleted things, but added others. I’m not sure if I respect all the
openrc standards as I’m not very comfortable with it.
I added a check_run() function because I want to use the bird config
parser if it’s running.
I added my own stop() function because bird has to wait for all the
sessions to be closed before killing the process.
I don’t know if I should make the configuration file and the sock file
configurable with /etc/conf.d/bird
I’m open to your comments and improvements :)
My script behave like this:
judicael-ovpn2 ~ # ps aux | grep bird
root 3928 0.0 0.3 25752 7944 pts/1 S+ Mar04 0:04 vim /etc/init.d/bird
root 5250 0.0 0.1 10860 2052 pts/3 S+ 11:31 0:00 grep --colour=auto bird
judicael-ovpn2 ~ # rc-service bird start
* Starting bird ... [ ok ]
judicael-ovpn2 ~ # ps aux | grep bird
root 3928 0.0 0.3 25752 7944 pts/1 S+ Mar04 0:04 vim /etc/init.d/bird
root 5383 62.8 1.8 42184 37080 ? Rs 11:31 0:03 /usr/sbin/bird -c /etc/bird.conf -s /var/run/bird.ctl -P /var/run/bird.pid
root 5400 0.0 0.1 10860 2236 pts/3 S+ 11:31 0:00 grep --colour=auto bird
judicael-ovpn2 ~ # birdc 'sh pr'
BIRD 2.0.4 ready.
Name Proto Table State Since Info
device1 Device --- up 11:31:26.782
direct1 Direct --- up 11:31:26.782
kernel_ipv4 Kernel master4 up 11:31:26.782
kernel_ipv6 Kernel master6 up 11:31:26.782
ibgp_nominoe_ipv4 BGP --- up 11:31:28.777 Established
ibgp_nominoe_ipv6 BGP --- up 11:31:28.205 Established
ibgp_budic_ipv4 BGP --- up 11:31:30.703 Established
ibgp_budic_ipv6 BGP --- up 11:31:28.614 Established
ospf_ipv4 OSPF master4 up 11:31:26.782 Running
ospf_ipv6 OSPF master6 up 11:31:26.782 Running
judicael-ovpn2 ~ # rc-service bird reload
* Reloading BIRD ... [ ok ]
judicael-ovpn2 ~ # rc-service bird restart
* Stopping BIRD ...
* Starting bird ... [ ok ]
judicael-ovpn2 ~ # rc-service bird status
* status: started
So basically it works, and the error check as well:
judicael-ovpn2 ~ # echo 'ezf' >> /etc/bird.conf
judicael-ovpn2 ~ # rc-service bird reload
* /etc/bird.conf:121:1 syntax error, unexpected SYM
judicael-ovpn2 ~ # rc-service bird restart
* Caching service dependencies ... [ ok ]
* /etc/bird.conf:121:1 syntax error, unexpected SYM
* ERROR: bird failed to stop
judicael-ovpn2 ~ # sed -i '$d' /etc/bird.conf
judicael-ovpn2 ~ # rc-service bird reload
* Reloading BIRD ... [ ok ]
--
Alarig
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-05 11:03 ` Alarig Le Lay
@ 2019-03-05 15:01 ` Michael Orlitzky
2019-03-05 16:24 ` Alarig Le Lay
2019-04-05 20:55 ` Alarig Le Lay
0 siblings, 2 replies; 8+ messages in thread
From: Michael Orlitzky @ 2019-03-05 15:01 UTC (permalink / raw
To: gentoo-user
On 3/5/19 6:03 AM, Alarig Le Lay wrote:
> Okay, I tried to write another script:
> https://git.grifon.fr/alarig/SwordArMor-gentoo-overlay/src/branch/master/net-misc/bird/files/initd-bird-2
>
> I deleted things, but added others. I’m not sure if I respect all the
> openrc standards as I’m not very comfortable with it.
That's OK, it already looks a lot better. And it works, which is nice =)
>
> I added a check_run() function because I want to use the bird config
> parser if it’s running.
You probably want to specify the config file in check_run(). You might
refactor the command_args as follows,
client_args="-c ${CONF_FILE} -s ${SOCK}"
command_args="${client_args} -P ${pidfile}"
and then in check_run, you can use "birdc ${client_args}..."
>
> I added my own stop() function because bird has to wait for all the
> sessions to be closed before killing the process.
There's a "retry" variable that you can set at the top-level:
retry Retry schedule to use when stopping the daemon. It can
either be a timeout in seconds or multiple signal/time‐
out pairs (like SIGTERM/5).
(from "man openrc-run")
The default stop() function will use that, so you shouldn't need to
write your own stop() if you set "retry=15".
>
> I’m open to your comments and improvements :)
>
The checkconfig() function isn't used any more, so it can be deleted. So
long as bird crashes with an error like "no config file!" when the file
is missing, I don't think you need to check for it yourself.
These days /var/run is simply a symlink to /run, so those two paths can
be shortened.
Once you've used it for a while and are confident that everything works,
please file a bug to include the improved script in the tree!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-05 15:01 ` Michael Orlitzky
@ 2019-03-05 16:24 ` Alarig Le Lay
2019-03-05 19:45 ` Michael Orlitzky
2019-04-05 20:55 ` Alarig Le Lay
1 sibling, 1 reply; 8+ messages in thread
From: Alarig Le Lay @ 2019-03-05 16:24 UTC (permalink / raw
To: gentoo-user
Thanks for you help!
I just did one think differently, I explain it inline.
I will run bird 2.0.4 on my lab for the rest of the week, then I will
upgrade the production network gradually. I will propose my script to
the tree if it all succeeds.
On mar. 5 mars 10:01:08 2019, Michael Orlitzky wrote:
> On 3/5/19 6:03 AM, Alarig Le Lay wrote:
> > Okay, I tried to write another script:
> > https://git.grifon.fr/alarig/SwordArMor-gentoo-overlay/src/branch/master/net-misc/bird/files/initd-bird-2
> >
> > I deleted things, but added others. I’m not sure if I respect all the
> > openrc standards as I’m not very comfortable with it.
>
> That's OK, it already looks a lot better. And it works, which is nice =)
Hehe :)
> You probably want to specify the config file in check_run(). You might
> refactor the command_args as follows,
>
> client_args="-c ${CONF_FILE} -s ${SOCK}"
> command_args="${client_args} -P ${pidfile}"
>
> and then in check_run, you can use "birdc ${client_args}..."
The client doesn’t care about the configuration file, only about the
socket. However, I factored the socket and then added -r to restrict
read-only commands, in order to avoid protocol disabling during the
check.
“Option -r can be used to enable a restricted mode of BIRD client, which
allows just read-only commands (show ...).”
-- https://bird.network.cz/?get_doc&v=20&f=bird-4.html
client_args="-s ${SOCK}"
command_args="${client_args} -c ${CONF_FILE} -P ${pidfile}"
client_args="${client_args} -r"
I also factored my `birdc config check` command in check_run().
--
Alarig
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-05 16:24 ` Alarig Le Lay
@ 2019-03-05 19:45 ` Michael Orlitzky
2019-03-06 9:54 ` Alarig Le Lay
0 siblings, 1 reply; 8+ messages in thread
From: Michael Orlitzky @ 2019-03-05 19:45 UTC (permalink / raw
To: gentoo-user
On 3/5/19 11:24 AM, Alarig Le Lay wrote:
>
> The client doesn’t care about the configuration file, only about the
> socket.
Oh, sorry, I was reading the wrong part of the man page.
It looks like you *can* specify which config file to check, but in a
different way:
configure check ["config file"]
Read and parse given config file, but do not use it. useful for
checking syntactic and some semantic validity of an config file.
So you'd want something like "configure check ${CONF_FILE}" I guess.
That way if you ever have two instances of bird running, reloading the
second instance won't check the config file for the first instance.
And "-r" was a good idea.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-05 19:45 ` Michael Orlitzky
@ 2019-03-06 9:54 ` Alarig Le Lay
0 siblings, 0 replies; 8+ messages in thread
From: Alarig Le Lay @ 2019-03-06 9:54 UTC (permalink / raw
To: gentoo-user
On mar. 5 mars 14:45:46 2019, Michael Orlitzky wrote:
> Oh, sorry, I was reading the wrong part of the man page.
>
> It looks like you *can* specify which config file to check, but in a
> different way:
>
> configure check ["config file"]
>
> Read and parse given config file, but do not use it. useful for
> checking syntactic and some semantic validity of an config file.
>
> So you'd want something like "configure check ${CONF_FILE}" I guess.
> That way if you ever have two instances of bird running, reloading the
> second instance won't check the config file for the first instance.
You’re right, I added it:
BIRD_CHECK_CONF="birdc ${client_args} configure check \"${CONF_FILE}\""
--
Alarig
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Question about bird init script
2019-03-05 15:01 ` Michael Orlitzky
2019-03-05 16:24 ` Alarig Le Lay
@ 2019-04-05 20:55 ` Alarig Le Lay
1 sibling, 0 replies; 8+ messages in thread
From: Alarig Le Lay @ 2019-04-05 20:55 UTC (permalink / raw
To: gentoo-user
Hi!
On mar. 5 mars 10:01:08 2019, Michael Orlitzky wrote:
> Once you've used it for a while and are confident that everything works,
> please file a bug to include the improved script in the tree!
All my bird instances are running with my script and I didn’t run in any
issue so far, so I opened a bug to propose it:
https://bugs.gentoo.org/682628
--
Alarig
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-04-05 20:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-04 10:33 [gentoo-user] Question about bird init script Alarig Le Lay
2019-03-04 14:05 ` Michael Orlitzky
2019-03-05 11:03 ` Alarig Le Lay
2019-03-05 15:01 ` Michael Orlitzky
2019-03-05 16:24 ` Alarig Le Lay
2019-03-05 19:45 ` Michael Orlitzky
2019-03-06 9:54 ` Alarig Le Lay
2019-04-05 20:55 ` Alarig Le Lay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox