On 29/03/13 00:39, Leonid Isaev wrote:
On Thu, 28 Mar 2013 18:23:03 +1100 Robbie Smith <zoqaeski@gmail.com> wrote:
TL;DR: More toying with mobile broadband and systemd; would like help automatically stopping service depending on device availability.
[...]
What I cannot figure out how to do is automatically stop the service if the device is unplugged, similar to how ifplugd works for wired ethernet interfaces.
How about "BindsTo=" from man 5 systemd.unit? For example, "BindsTo=sys-subsystem-net-devices-wap.device".
That looks like the right starting point. “PartOf=” seems like it’s intended to control units, not devices. There’s a slight problem though: not only are the device names quite verbose[*], they aren’t persistent. Only the lowest-numbered USB serial port will communicate with the device; usually this is /dev/ttyUSB0 but sometimes it’s not. I have no idea what the other two or three do, and I couldn’t find documentation on minicom (or similar) to be able to probe them. The new Linux persistent naming rules don’t apply to these devices, and udev rules seem so arcane I could never figure out how to write a rule that would give a consistent name to the accessible port. [*] There do appear to be aliases to their names in /dev/, so this probably isn’t an issue.