On Sun, Oct 9, 2011 at 7:52 AM, Mirco Tischler <mt...@gmx.de> wrote: > 2011/10/9 Cliff Brake <cliff.br...@gmail.com>: >> On Sat, Oct 8, 2011 at 11:09 AM, Cliff Brake <cliff.br...@gmail.com> wrote: >> However, it does not work for subsequent NIC insertions. It appears >> that stop is not getting executed when the device is removed, as >> network@eth0.service is always listed as active after the NIC is >> installed, and then removed. > Hmm, true. I wonder if the ExecStop line is really necessary, as it > doesn't make sense to execute this after the device is plugged out. So > if you drop this, you can drop the RemainAfterExit as well and it > should work for subsequent insertions.
It appears that two things need to happen: 1) we need to run ifdown, as ifup/down keeps track of state in /var/run/ifstate: root@cm-x270:~# more /var/run/ifstate eth0=eth0 2) somehow systemd needs to know the interface is stopped before it will try to start it. It does not appear that removing the device currently is triggering any systemd events. After I remove the NIC: root@cm-x270:~# systemctl status network@eth0.service network@eth0.service Loaded: loaded (/lib/systemd/system/network@.service; static) Active: active (exited) since Mon, 10 Oct 2011 04:48:42 -0500; 47s ago Process: 419 ExecStop=/sbin/ifdown %i (code=exited, status=0/SUCCESS) Process: 427 ExecStart=/sbin/ifup %i (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/network@.service/eth0 └ 446 udhcpc -R -n -p /var/run/udhcpc.eth0.pid -i eth0 root@cm-x270:~# more /var/run/ifstate eth0=eth0 > Another way that comes to mind might be to add > ENV{SYSTEMD_ALIAS}="/$name" to the udev rule and add > "BindTo=%i.device" in the unit section of the service file. One thing I've been struggling with is finding documentation. For instance with BindTo, I start clicking on man pages here http://0pointer.de/public/systemd-man/. I guessed systemd.service.hml first, but after several tries found it at systemd.unit.html. I would be very handy to have all the man pages in one HTML or PDF page, as it seems like this is the best source of systemd documentation that I've found to date. It seems BindTo is ideal for this case, so I'll try it next, thanks for the idea! BindTo= Configures requirement dependencies, very similar in style to Requires=, however in addition to this behaviour it also declares that this unit is stopped when any of the units listed suddenly disappears. Units can suddenly, unexpectedly disappear if a service terminates on its own choice, a device is unplugged or a mount point unmounted without involvement of systemd. Cliff -- ================= http://bec-systems.com _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel