Automatically stop systemd service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



TL;DR: More toying with mobile broadband and systemd; would like help automatically stopping service depending on device availability.

I’ve been adjusting the .service file for netcfg@ppp-mobile.service so it plays nicely with my modem. It will only start if the USB modem is plugged in and exposing a serial port to the computer, and when I manaually stop the unit, the ppp daemon is also killed, so it doesn’t lock the device and reconnect automatically upon the device being detected again, thus *bringing up the network interface when systemd and netcfg say it is down*.

    /etc/systemd/system/netcfg@ppp-mobile.service:
    ----------------------------------------------
    .include /usr/lib/systemd/system/netcfg@.service
    [Unit]
Description=Netcfg networking service for mobile broadband point to-point protocol.
    ConditionPathExists=/dev/ttyUSB0

    [Service]
    KillMode=control-group


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.

I’ve read the manual pages and asked Google, and I cannot seem to find more detailed information. I think it may be possible to write a service that will use udev’s polling capabilities, but then I have to somehow link that unit to the netcfg one such that it gets stopped and started when netcfg is, which implies it would listen to udev, wait for the device to be unplugged, then stop netcfg and kill itself.

systemd's PartOf= may offer an answer, but I don’t really know how to tie it all together.

How should I best go about this? Another systemd service, a udev rule, or is it possible to further modify the ppp-mobile service?

regards,
Robbie


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux