systemd - standard place to run stuff after the network is up?
mzerqung at 0pointer.de
Mon Oct 17 17:10:04 UTC 2011
On Mon, 17.10.11 09:20, Bruno Wolff III (bruno at wolff.to) wrote:
> I want to try to modprobe netconsole during boot, but it needs to happen
> after the network is up. Is there any standard place (rc.local and
> modules-load seem to happen too early) to do this?
Well, yes and no.
In general doing something like this is a bit backwards since networks
come and go and come and go in todays world, and we also don't want to
make normal system bootup dependent on external circumstances such as a
DHCP server responding or so, if we can avoid it.
So, while my first response to this would be the suggestion to improve
the sw in question to make it more robust to today's dynamic networking
I do acknowledge that this is not always feasible. So
here's what you can do instead:
Write a tiny service file /etc/systemd/system/foobar.service:
Then symlink it to /etc/systemd/system/multi-user.target.wants/.
(That all assuming this is just something to use locally. If you want
something you can stick in an RPM add an [Install] section with
"WantedBy=multi-user.target" to the above, and move the unit file from
/etc to /lib, and create the symlink with systemctl enable. Also,
addding a Description= in [Unit] would be cool too).
Note that you might still need to enable
NetworkManager-wait-online.servce with "systemctl enable" so that bootup
is delayed until NM configured a network. (more precisely: delay
network.target until NM configured a network).
Lennart Poettering - Red Hat, Inc.
More information about the devel