[arch-general] Automatically stop systemd service

Leonid Isaev lisaev at umail.iu.edu
Thu Mar 28 11:13:00 EDT 2013

On Fri, 29 Mar 2013 01:48:55 +1100
Robbie Smith <zoqaeski at gmail.com> wrote:

> 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
> >> interfaces.
> >
> > How about "BindsTo=" from man 5 systemd.unit? For example,
> > "BindsTo=sys-subsystem-net-devices-wap.device".
> >
> That did the trick (when the device is /dev/ttyUSB0). Now to just make a 
> persistent name for the rare occasions when it appears as something else 
> (always a /dev/ttyUSBx).

Glad to help :)

Regarding the persistend device names, you'll have to place a udev rule
in /etc/udev/rules.d/, e.g. (there is also an archwiki page on this)
SUBSYSTEM=="net", ATTR{address}=="<MAC>", NAME="wan"
Although this is for a network card (I have never seen a 3g/4g modem). You'll
have to run something like "udevadm info --path=/sys/class/net/wan
--attribute-walk" replacing 'wan' with your device name to find persistent


Leonid Isaev
GnuPG key: 0x164B5A6D
Fingerprint: C0DF 20D0 C075 C3F1 E1BE  775A A7AE F6CB 164B 5A6D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.archlinux.org/pipermail/arch-general/attachments/20130328/a0252290/attachment-0001.asc>

More information about the arch-general mailing list