[systemd-devel] Ensuring that a unit starts before any networking
Mark Rogers
mark at more-solutions.co.uk
Sat Jun 27 08:34:00 UTC 2020
This feels like something I should be easily able to answer from
documentation/Google, and failing that from somewhere like
StackOverflow, without troubling systemd-devel, but all my efforts
have thus far failed [1]
What is the correct way to ensure a script runs to completion before
any networking units start? "The Internet" is abound with people
asking the opposite question which hasn't helped my keyword-based
searches.
My use case (on a Raspberry Pi running Raspbian if it matters) is that
I have network settings stored in a database from which I generate
network configuration files (eg dhcpcd.conf) on boot, therefore they
obviously need to be in place before dhcpcd starts. (Similarly
wpa_supplicant.)
Ideally I'd like to be agnostic about the actual network stack in my
unit configuration (so not setting dependencies relating to dhcpcd,
for example) but at this point I've tried pretty much everything
without success so I'm obviously doing something stupid.
I have tried multiple approaches so far but by current service file
looks like this:
[Unit]
Description=Config generation from DB
Before=networking.service
[Service]
Type=oneshot
ExecStart=/home/mark/bin/db2config.py
[Install]
RequiredBy=network.target
[1] https://stackoverflow.com/questions/62574482/ensuring-that-a-systemd-unit-starts-before-any-networking
- no responses there to date, feel free to respond there for
reputation or else I'll update it when I solve it.
--
Mark Rogers
More information about the systemd-devel
mailing list