systemd - standard place to run stuff after the network is up?

Simo Sorce simo at redhat.com
Mon Oct 17 17:21:26 UTC 2011


On Mon, 2011-10-17 at 19:10 +0200, Lennart Poettering wrote:
> 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:
> 
> <snip>
> [Unit]
> After=network.target
> 
> [Service]
> ExecStart=...
> </snip>
> 
> 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).

If this is done does it mean a potentially high number of services is
started only after a user logged in and attached to a wireless spot ?

Or will NetworkManager-wait-online.servce wait only for networks marked
as to be enable on boot ?

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York



More information about the devel mailing list