On Sat, Apr 13, 2013 at 12:30:33PM +0100, Colin Guthrie wrote: > 'Twas brillig, and Léo Gillot-Lamure at 13/04/13 11:11 did gyre and gimble: > > Hi. > > Would it be possible to bind something to the start and stop actions of > > a device unit ? > > I've got a device (a hard drive) that I can programmatically plug/unplug > > using commands such as "echo '0 0 0' > /sys/class/scsi_host/host1/ > > scan" > > and "echo 1 > >> > > /sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/delete". > > The goal is reducing noise. > > It would be nice to bind these commands in the device unit itself so > > that other units needing it can start it by themselves, etc. > > So I think this should just be a matter of creating a .service unit with > appropriate ExecStart/Stop directives and then add a BindTo= directive > to bind it to the device.
BindTo= would give the opposite ordering than the one required. I think that RequiredBy=...device, Before=....device, StopWhenUnneeded=true (in the plug-unplug.unit) should give you what you need. It might make sense to make the plug-unplug.unit a template, so that you can enable it for a device by saying 'systemctl enable [email protected]'. Zbyszek _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
