Comment 3 for bug 1721839

Revision history for this message
Till Kamppeter (till-kamppeter) wrote : Re: Services asked for by UDEV do not get triggered

It seems that with a 70-printers.rules as follows at least a correct service name is generated

----------
# Low-level USB device add trigger
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", TAG+="udev-configure-printer", TAG+="systemd", PROGRAM="/bin/systemd-escape --template=udev-configure-printer@.service %p", ENV{SYSTEMD_WANTS}+="'%c'"
# Low-level USB device remove trigger
ACTION=="remove", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701*:*", RUN+="udev-configure-printer remove %p"
----------

Note that in the first rule the systemd-escape command has NO "-p" option and that the %c for ENV{SYSTEMD_WANTS} has extra single quotes. Compared to the original file only these single quotes got added.

After restarting UDEV with

sudo udevadm control --reload

and re-plugging the printer in most cases the service does not get started.

systemctl status 'udev-configure-printer@-devices-pci0000:00-0000:00:14.0-usb2-2\x2d2.service' > status.txt

gives something like

----------
● udev-configure-printer@devices-pci0000:00-0000:00:14.0-usb2-2\x2d2.service - Automatic USB/Bluetooth printer setup (devices-pci0000:00-0000:00:14.0-usb2-2\x2d2)
   Loaded: loaded (/lib/systemd/system/udev-configure-printer@.service; static; vendor preset: enabled)
   Active: inactive (dead)
----------

In such a case one can start the service manually with

sudo systemctl start 'udev-configure-printer@-devices-pci0000:00-0000:00:14.0-usb2-2\x2d2.service'

and this starts correctly udev-configure printer which sets up the printer (and starts ippusbxd if needed).

In some very few cases the service actually gets correctly started (and the printer set up) when one plugs the printer, but this happens rarely (can there be some kind of race condition?).

So this only rarely happening automatic start of the printer setup service is now the problem. The escaping seems to be fixed by the extra single quotes.