[systemd-devel] Ensuring that a unit starts before any networking

Mark Rogers mark at more-solutions.co.uk
Sat Jun 27 10:42:00 UTC 2020


On Sat, 27 Jun 2020 at 11:06, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> You should use Before=network-pre.target, Wants=network-pre.target.

Thanks, tried that but still not working:

$ journalctl -b | grep -Ei '(db2config|dhcpcd)'
Feb 14 10:12:03 localhost systemd[1]: Starting dhcpcd on all interfaces...
Feb 14 10:12:03 localhost dhcpcd[341]: read_config: fopen
`/etc/dhcpcd.conf': No such file or directory
[...]
Jun 27 10:19:39 localhost dhcpcd[341]: wlan0: /etc/wpa_supplicant.conf
does not exist
[...]
Jun 27 10:19:39 localhost dhcpcd[341]: read_config: fopen
`/etc/dhcpcd.conf': No such file or directory
[...]
Jun 27 10:19:40 localhost dhcpcd[341]: eth0: soliciting an IPv6 router
Jun 27 10:19:40 localhost dhcpcd[341]: eth0: soliciting a DHCP lease
Jun 27 10:19:41 mypi db2config.py[325]: 2020-06-27 10:19:41 db2config
Creating /tmp/sys//etc/dhcpcd.conf
Jun 27 10:19:41 mypi db2config.py[325]: 2020-06-27 10:19:41 db2config
Creating /tmp/sys//etc/wpa_supplicant/wpa_supplicant.conf

(Comments about that extract: the jump from Feb to Jun I assume is the
clock getting updated from RTC, it's all from the same boot obviously;
also note my db2config script doesn't run until after hostname is set
which I would assume is set by the network startup?)

Unit file is currently:

[Unit]
Description=Config generation from DB
Before=network-pre.target
Wants=network-pre.target

[Service]
Type=oneshot
ExecStart=/home/mark/bin/db2config.py

[Install]
RequiredBy=network.target

After any changes I'm using
$ sudo systemctl daemon-reload
$ sudo systemctl reenable db2config.service

... although that's another area I'm not entirely clear about what
exactly is required after a unit file change.

PS: Is list etiquette around here to CC on reply? Some love it, some
hate it, others don't care...


--
Mark Rogers


More information about the systemd-devel mailing list