I wrote two udev
rules which worked fine until the introduction of systemctl
.
These rules run a daemon whenever a kind of USB device is plugged in and stop the same daemon when the same device is unplugged. This is done with an helper script myscript
.
With systemctl
the problem now is that it apparently kills the daemon invoked by myscript
after some seconds the device is plugged in.
The rules are the following:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{VID_PID}="%s{idVendor}:%s{idProduct}", ACTION=="add", RUN+="/etc/init.d/myscript plug %E{VID_PID}"`
SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", ENV{VID_PID}="%E{ID_VENDOR_ID}:%E{ID_MODEL_ID}", RUN+="/etc/init.d/myscript unplug %E{VID_PID}"`
Note that the myscript
accepts two arguments: the action plug or unplug and the device identifiers.
Do you know how to fix the problem or how to implement the same - if necessary - in terms of systemctl
?