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

Reply via email to