[systemd-devel] SYSTEMD_WANTS and oneshot services

Albert Strasheim fullung at gmail.com
Sun Aug 21 05:01:26 PDT 2011


Hello all

After my misadventures with SYSTEMD_ALIAS, I've tried to do it with
SYSTEMD_WANTS instead.

My udev rule:

SUBSYSTEM=="net", NAME=="em[1-2]", TAG+="systemd",
ENV{SYSTEMD_WANTS}="foo-net-$name.service"

And my foo-net-em1.service unit (just calls the existing network
scripts for now):

[Unit]
Requires=foo-configure.service
After=foo-configure.service

[Service]
# using the old network scripts for now
ExecStart=/sbin/ifup em1
Type=oneshot
TimeoutSec=0
RemainAfterExit=no

When the machine boots, the unit runs and configures my interface.

After that, if I do:

rmmod igb (my network card's module)
modprobe igb

systemd does not run foo-net-em1.service again. I tried with both
RemainAfterExit=yes|no.

However, if I do:

rmmod igb
systemctl daemon-reload
modprobe igb

systemd does run foo-net-em1.service again.

Is there a way to always get this behavior? I'd like my network
interfaces to be brought up regardless of how and when their modules
are loaded.

Regards

Albert

P.S. With biosdevname in F15, I'm not sure that
ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/%k" is the most useful
thing. Users might want $name instead of %k?


More information about the systemd-devel mailing list