Re: bird systemd startup init debian

2018-03-07 Thread Toke Høiland-Jørgensen
Ondrej Zajicek  writes:

> On Tue, Mar 06, 2018 at 12:26:02PM +0100, Toke Høiland-Jørgensen wrote:
>> Rob Lister  writes:
>> 
>> > root@rs1f:/etc/bird# service bird start
>> > Job for bird.service failed because the control process exited with 
>> > error code.
>> > See "systemctl status bird.service" and "journalctl -xe" for details.
>> >
>> > root@rs1f:/etc/bird# systemctl status bird.service
>> > ● bird.service - BIRD Internet Routing Daemon (IPv4)
>> > Loaded: loaded (/lib/systemd/system/bird.service; enabled; vendor 
>> > preset: enabled)
>> >Drop-In: /etc/systemd/system/bird.service.d
>> > └─override.conf
>> > Active: failed (Result: exit-code) since Mon 2018-03-05 19:16:16 UTC; 
>> > 8s ago
>> >Process: 510 ExecStartPre=/usr/sbin/bird -p (code=exited, 
>> > status=1/FAILURE)
>> 
>> So this says that it's `bird -p` that fails. This is a check of the
>> configuration file before the actual daemon is started. Since that is
>> not passed the $BIRD_ARGS (as you can see from the command line
>> invocation), it fails, which prevents startup of the actual daemon.
>> 
>> You'd have to add the same $BIRD_RUN_USER, $BIRD_RUN_GROUP and
>> $BIRD_ARGS to the ExecStartPre line I guess; the fact that it is not
>> there already is a bug in the systemd unit file, I'd say. I guess this
>> is a packaging bug on the Debian side? In which case you should open a
>> bug in the Debian system :)
>
> Well, the only option that is necessary to add to ExecStartPre is the
> option -c for the config file. But other options there are probably
> harmless.

I was mostly thinking that the user and group should be there because
that can influence whether or not the config file is readable; but it
depends on whether bird actually drops privileges in -p mode.

> Unfortunately with systemd we cannot find a better way to get sane
> behavior w.r.t. config file errors than execute BIRD two times (one in
> parser-only mode).

What's wrong with just exiting the main process on config file errors?
Why is the pre-check needed?

-Toke



Re: bird systemd startup init debian

2018-03-07 Thread Ondrej Zajicek
On Tue, Mar 06, 2018 at 12:26:02PM +0100, Toke Høiland-Jørgensen wrote:
> Rob Lister  writes:
> 
> > root@rs1f:/etc/bird# service bird start
> > Job for bird.service failed because the control process exited with 
> > error code.
> > See "systemctl status bird.service" and "journalctl -xe" for details.
> >
> > root@rs1f:/etc/bird# systemctl status bird.service
> > ● bird.service - BIRD Internet Routing Daemon (IPv4)
> > Loaded: loaded (/lib/systemd/system/bird.service; enabled; vendor 
> > preset: enabled)
> >Drop-In: /etc/systemd/system/bird.service.d
> > └─override.conf
> > Active: failed (Result: exit-code) since Mon 2018-03-05 19:16:16 UTC; 
> > 8s ago
> >Process: 510 ExecStartPre=/usr/sbin/bird -p (code=exited, 
> > status=1/FAILURE)
> 
> So this says that it's `bird -p` that fails. This is a check of the
> configuration file before the actual daemon is started. Since that is
> not passed the $BIRD_ARGS (as you can see from the command line
> invocation), it fails, which prevents startup of the actual daemon.
> 
> You'd have to add the same $BIRD_RUN_USER, $BIRD_RUN_GROUP and
> $BIRD_ARGS to the ExecStartPre line I guess; the fact that it is not
> there already is a bug in the systemd unit file, I'd say. I guess this
> is a packaging bug on the Debian side? In which case you should open a
> bug in the Debian system :)

Well, the only option that is necessary to add to ExecStartPre is the
option -c for the config file. But other options there are probably
harmless.

Unfortunately with systemd we cannot find a better way to get sane
behavior w.r.t. config file errors than execute BIRD two times (one
in parser-only mode).

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santi...@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."




Re: bird systemd startup init debian

2018-03-06 Thread Rob Lister


Yes - thanks for that hint :)

The error "bird: Unable to open configuration file /etc/bird/bird.conf" 
appears in red text while

the smaller more critical reason does not stand out so much.

BIRD_ARGS in /etc/init.d/bird seems not to work (something else is 
overriding it?)


Both bird and bird6 pick up from /etc/bird/envvars but we need to define 
separate configuration files for bird and bird6.


My eventual fix for this:-

cp /etc/bird/bird.conf /etc/bird/bird-vlanid1-ipv4.conf
cp /etc/bird/bird.conf /etc/bird/bird-vlanid1-ipv6.conf
rm /etc/bird/bird.conf

cp /etc/bird/envvars /etc/bird/envvars6

echo "BIRD_ARGS=\"-c /etc/bird/bird-vlanid1-ipv4.conf\"" >> envvars
echo "BIRD_ARGS=\"-c /etc/bird/bird-vlanid1-ipv6.conf\"" >> envvars6

systemctl edit bird :

# bird.service
[Service]
ExecStart=
ExecStart=/usr/sbin/bird -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP 
$BIRD_ARGS

ExecStartPre=
ExecStartPre=/usr/sbin/bird -p -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP 
$BIRD_ARGS


systemctl edit bird6 :
# bird6.service
[Service]
EnvironmentFile=
EnvironmentFile=/etc/bird/envvars6
ExecStart=
ExecStart=/usr/sbin/bird6 -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP 
$BIRD_ARGS

ExecStartPre=
ExecStartPre=/usr/sbin/bird6 -p -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP 
$BIRD_ARGS



On 2018-03-06 11:26, Toke Høiland-Jørgensen wrote:

   Process: 510 ExecStartPre=/usr/sbin/bird -p (code=exited,
status=1/FAILURE)


So this says that it's `bird -p` that fails. This is a check of the
configuration file before the actual daemon is started. Since that is
not passed the $BIRD_ARGS (as you can see from the command line
invocation), it fails, which prevents startup of the actual daemon.

You'd have to add the same $BIRD_RUN_USER, $BIRD_RUN_GROUP and
$BIRD_ARGS to the ExecStartPre line I guess; the fact that it is not
there already is a bug in the systemd unit file, I'd say. I guess this
is a packaging bug on the Debian side? In which case you should open a
bug in the Debian system :)

-Toke


--
Rob Lister
r...@lonap.net


Re: bird systemd startup init debian

2018-03-06 Thread Jan Maria Matejka
> root@rs1f:/etc/bird# systemctl status bird.service

[...]

>   Process: 510 ExecStartPre=/usr/sbin/bird -p (code=exited, status=1/FAILURE)

Here is the problem, this command failed.

> root@rs1f:/etc/init# cat /lib/systemd/system/bird.service

[...]

> ExecStartPre=/usr/sbin/bird -p

Here it uses the default config path. This command checks the bird config for 
validity.

Maria


Re: bird systemd startup init debian

2018-03-06 Thread Rob Lister

On 2018-03-06 09:42, Wilco Baan Hofman wrote:
I need to specify during startup "-c /path/to/config/file" but 
whatever

I do, it just gets ignored and still tries to use /etc/bird/bird.conf

I have tried:

- Editing /etc/init.d/bird and adding BIRD_ARGS="-c
/etc/bird/bird-vlanid1-ipv4.conf"
- Editing /etc/defaults/bird (deprecated??)


Editing arguments should be done in /etc/defaults/bird, not in 
/etc/init.d.


Yes, I tried both and neither worked, though the file does not exist by 
default

(this is where the options are changed on our existing route servers.)



- Editing /etc/bird/envvars
- Editing the systemctl with "systemctl edit bird.service" as 
suggested

here:

https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1503154.html

- Restarting systemctl daemon-reload


This only re-reads the systemd configuration file. Try "service bird
restart" (because reload only causes bird to reread the bird config and
if you want new command line arguments, restart bird)


Yes, tried that but it won't start while it can't find 
/etc/bird/bird.conf, and I can't seem to tell it to use an alternative 
configuration file. I've tried all of:-


root@rs1f:/etc/bird# cat /etc/bird/envvars
BIRD_RUN_USER=bird
BIRD_RUN_GROUP=bird
BIRD_ARGS="-c /etc/bird/bird-vlanid1-ipv4.conf"

root@rs1f:/etc/bird# cat 
/etc/systemd/system/bird.service.d/override.conf

# bird.service
[Service]
ExecStart=
ExecStart=/usr/sbin/bird -c /etc/bird/bird-vlanid1-ipv4.conf -f -u 
$BIRD_RUN_USER -g $BIRD_RUN_GROUP $BIRD_ARGS -P /var/run/bird/bird.pid


root@rs1f:/etc/bird# grep BIRD_ARGS /etc/init.d/bird
BIRD_ARGS="-c /etc/bird/bird-vlanid1-ipv4.conf"

root@rs1f:/etc/default# cat /etc/default/bird
#
# This is a POSIX shell fragment
#

# Additional options that are passed to the Daemon.
BIRD_ARGS="-c /etc/bird/bird-vlanid1-ipv4.conf -s 
/var/run/bird/bird-vlanid1-ipv4.ctl"



Also tried the old "DAEMON_ARGS" here but doesn't look like the script 
uses it.



But whatever I try doesn't get passed to bird:-


root@rs1f:/etc/bird# service bird start
Job for bird.service failed because the control process exited with 
error code.

See "systemctl status bird.service" and "journalctl -xe" for details.

root@rs1f:/etc/bird# systemctl status bird.service
● bird.service - BIRD Internet Routing Daemon (IPv4)
   Loaded: loaded (/lib/systemd/system/bird.service; enabled; vendor 
preset: enabled)

  Drop-In: /etc/systemd/system/bird.service.d
   └─override.conf
   Active: failed (Result: exit-code) since Mon 2018-03-05 19:16:16 UTC; 
8s ago
  Process: 510 ExecStartPre=/usr/sbin/bird -p (code=exited, 
status=1/FAILURE)
  Process: 504 ExecStartPre=/usr/lib/bird/prepare-environment 
(code=exited, status=0/SUCCESS)


Mar 05 19:16:16 rs1f.lonap.net systemd[1]: Starting BIRD Internet 
Routing Daemon (IPv4)...
Mar 05 19:16:16 rs1f.lonap.net bird[510]: Unable to open configuration 
file /etc/bird/bird.conf: No such file or directory
Mar 05 19:16:16 rs1f.lonap.net bird[510]: bird: Unable to open 
configuration file /etc/bird/bird.conf: No such file or directory
Mar 05 19:16:16 rs1f.lonap.net systemd[1]: bird.service: Control process 
exited, code=exited status=1
Mar 05 19:16:16 rs1f.lonap.net systemd[1]: Failed to start BIRD Internet 
Routing Daemon (IPv4).
Mar 05 19:16:16 rs1f.lonap.net systemd[1]: bird.service: Unit entered 
failed state.
Mar 05 19:16:16 rs1f.lonap.net systemd[1]: bird.service: Failed with 
result 'exit-code'.



Seems that /etc/bird/envvars should be being read:

/etc/init/bird.conf


root@rs1f:/etc/init# cat /lib/systemd/system/bird.service
[Unit]
Description=BIRD Internet Routing Daemon (IPv4)
After=network.target

[Service]
EnvironmentFile=/etc/bird/envvars
ExecStartPre=/usr/lib/bird/prepare-environment
ExecStartPre=/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

[Install]
WantedBy=multi-user.target


After some further investigation, It would seem that something is 
checking for /etc/bird/bird.conf during startup regardless,

and failing even if this file is not specified:

If we do:

root@rs1f:/etc/bird# ln -s bird-vlanid1-ipv4.conf bird.conf

root@rs1f:/etc/bird# service bird start

root@rs1f:/etc/bird# !ps
ps xau | grep bird
bird   313  0.0  0.0  15332  2088 ?Ss   Mar05   0:00 
/usr/sbin/bird6 -f -u bird -g bird
bird  1609  0.0  0.0  15272  2084 ?Ss   10:49   0:00 
/usr/sbin/bird -f -u bird -g bird -c /etc/bird/bird-vlanid1-ipv4.conf


It appears that it took my config as specified from "/etc/bird/envvars" 
but that it cannot cope with /etc/bird/bird.conf not existing.
(We tried also just a blank /etc/bird/bird.conf but it doesn't like that 
- must be valid config file.)



Rob



--
Rob Lister
r...@lonap.net
+44 20 3137 8330


Re: bird systemd startup init debian

2018-03-06 Thread Wilco Baan Hofman


On 06/03/18 03:33, Rob Lister wrote:
> 
> Hi,
> 
> I'm working on upgrading our route servers to the latest versions
> (debian stretch and the bird debian package 1.6.3.
> 
> I need to specify during startup "-c /path/to/config/file" but whatever
> I do, it just gets ignored and still tries to use /etc/bird/bird.conf
> 
> I have tried:
> 
> - Editing /etc/init.d/bird and adding BIRD_ARGS="-c
> /etc/bird/bird-vlanid1-ipv4.conf"
> - Editing /etc/defaults/bird (deprecated??)

Editing arguments should be done in /etc/defaults/bird, not in /etc/init.d.


> - Editing /etc/bird/envvars
> - Editing the systemctl with "systemctl edit bird.service" as suggested
> here:
> 
> https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1503154.html
> 
> 
> 
> - Restarting systemctl daemon-reload

This only re-reads the systemd configuration file. Try "service bird
restart" (because reload only causes bird to reread the bird config and
if you want new command line arguments, restart bird)

--

Wilco


bird systemd startup init debian

2018-03-05 Thread Rob Lister


Hi,

I'm working on upgrading our route servers to the latest versions 
(debian stretch and the bird debian package 1.6.3.


I need to specify during startup "-c /path/to/config/file" but whatever 
I do, it just gets ignored and still tries to use /etc/bird/bird.conf


I have tried:

- Editing /etc/init.d/bird and adding BIRD_ARGS="-c 
/etc/bird/bird-vlanid1-ipv4.conf"

- Editing /etc/defaults/bird (deprecated??)
- Editing /etc/bird/envvars
- Editing the systemctl with "systemctl edit bird.service" as suggested 
here:


https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1503154.html


- Restarting systemctl daemon-reload

There is clearly some step I am missing to make it pick up the config 
change, but I can't find what it is.


Any help would be appreciated.

Thanks,


Rob



root@rs1f:~# systemctl status bird.service
● bird.service - BIRD Internet Routing Daemon (IPv4)
   Loaded: loaded (/lib/systemd/system/bird.service; enabled; vendor 
preset: enabled)

  Drop-In: /etc/systemd/system/bird.service.d
   └─override.conf
   Active: failed (Result: exit-code) since Mon 2018-03-05 19:11:50 UTC; 
19s ago
  Process: 305 ExecStartPre=/usr/sbin/bird -p (code=exited, 
status=1/FAILURE)
  Process: 280 ExecStartPre=/usr/lib/bird/prepare-environment 
(code=exited, status=0/SUCCESS)


Mar 05 19:11:49 rs1f.lonap.net systemd[1]: Starting BIRD Internet 
Routing Daemon (IPv4)...
Mar 05 19:11:50 rs1f.lonap.net bird[305]: Unable to open configuration 
file /etc/bird/bird.conf: No such file or directory
Mar 05 19:11:50 rs1f.lonap.net bird[305]: bird: Unable to open 
configuration file /etc/bird/bird.conf: No such file or directory
Mar 05 19:11:50 rs1f.lonap.net systemd[1]: bird.service: Control process 
exited, code=exited status=1
Mar 05 19:11:50 rs1f.lonap.net systemd[1]: Failed to start BIRD Internet 
Routing Daemon (IPv4).
Mar 05 19:11:50 rs1f.lonap.net systemd[1]: bird.service: Unit entered 
failed state.
Mar 05 19:11:50 rs1f.lonap.net systemd[1]: bird.service: Failed with 
result 'exit-code'.