[arch-general] Automatically stop systemd service
zoqaeski at gmail.com
Thu Mar 28 10:41:01 EDT 2013
On 29/03/13 00:39, Leonid Isaev wrote:
> On Thu, 28 Mar 2013 18:23:03 +1100
> Robbie Smith <zoqaeski at 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
> How about "BindsTo=" from man 5 systemd.unit? For example,
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
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.
More information about the arch-general