I'm running Arch Linux, and I have a udev rule which starts a service when a device is inserted. In this case, it dials a connection when a 3G modem is plugged in.
KERNEL=="ttyUSB*", SYMLINK=="gsmmodem", TAG+="systemd", ENV{SYSTEMD_WANTS}="netcfg@wvdial.service"
However, if the device is removed, systemd won't stop the service, and hence when it is plugged in again, it won't start the service, since it's already running.
What I need is a matching udev rule which runs when the device is removed to stop the service.