udev rules help
Jacek Konieczny
jajcus at jajcus.net
Wed Aug 31 09:47:30 CEST 2016
On 2016-08-31 07:28, Elan Ruusamäe wrote:
> i'm trying to write udev rule to start service when usb device is attached
>
> here's what i got. yet it doesn't work
>
> # grep add /etc/udev/rules.d/80-idcard.rules
> SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device",
> ENV{ID_MODEL}=="*Smart*Card*Reader*", RUN+="/sbin/service pcscd start"
What init do you use. This _might_ work with systemd, as 'service' just
shcedules a systemd job, but won't work with rc-scripts, as udev rules
are not allowed to start long running processes.
udev rules are not a place for starting daemons, which is well
documented thing.
> i even tried something very simple:
> ACTION=="add", RUN+="/sbin/service pcscd start"
>
> that also didn't work (attaching device did not start the service), how
> to debug this?
Just don't do this. Switch to systemd and use systemd device
dependencies in the .service file to start the service.
If you want to stick with rc-scripts, then wait for the device in the
init script.
Jacek
More information about the pld-devel-en
mailing list