Skip to main content
added 137 characters in body
Source Link
Gauthier
  • 909
  • 2
  • 18
  • 31

I am modifying my working udev rule (/etc/udev/rules.d/10-local.rules):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw"

to this (end of row):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw", TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service"

I have user service offnet-uart-log.service in ~/.config/systemd/user, which I can manually trigger, but I don't get this far yet.

With the added , TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service" at the end of my udev rule, the symlink is not created (I reload with sudo udevadm control --reload-rules && sudo udevadm trigger).

This tells me that the rule is wrong, but I don't know why. Could be related to udev being owned by root, while the service is owned by the user? Did I misunderstand WANTS?

I've tried all four combinations of SYSTEM_USER_WANTS or SYSTEM_WANTS, and = or +=. Removing the *_WANTS makes the symlink appear, so the error is in the *_WANTS.

How do I make my tty device trigger the log service?


EDIT: as mentioned in my own answer below, modifying SYSTEM_USER_WANTS to ENV{SYSTEM_USER_WANTS} works. Why is it required?

I am modifying my working udev rule (/etc/udev/rules.d/10-local.rules):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw"

to this (end of row):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw", TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service"

I have user service offnet-uart-log.service in ~/.config/systemd/user, which I can manually trigger, but I don't get this far yet.

With the added , TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service" at the end of my udev rule, the symlink is not created (I reload with sudo udevadm control --reload-rules && sudo udevadm trigger).

This tells me that the rule is wrong, but I don't know why. Could be related to udev being owned by root, while the service is owned by the user? Did I misunderstand WANTS?

I've tried all four combinations of SYSTEM_USER_WANTS or SYSTEM_WANTS, and = or +=. Removing the *_WANTS makes the symlink appear, so the error is in the *_WANTS.

How do I make my tty device trigger the log service?

I am modifying my working udev rule (/etc/udev/rules.d/10-local.rules):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw"

to this (end of row):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw", TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service"

I have user service offnet-uart-log.service in ~/.config/systemd/user, which I can manually trigger, but I don't get this far yet.

With the added , TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service" at the end of my udev rule, the symlink is not created (I reload with sudo udevadm control --reload-rules && sudo udevadm trigger).

This tells me that the rule is wrong, but I don't know why. Could be related to udev being owned by root, while the service is owned by the user? Did I misunderstand WANTS?

I've tried all four combinations of SYSTEM_USER_WANTS or SYSTEM_WANTS, and = or +=. Removing the *_WANTS makes the symlink appear, so the error is in the *_WANTS.

How do I make my tty device trigger the log service?


EDIT: as mentioned in my own answer below, modifying SYSTEM_USER_WANTS to ENV{SYSTEM_USER_WANTS} works. Why is it required?

Source Link
Gauthier
  • 909
  • 2
  • 18
  • 31

udev rule to trigger systemd service

I am modifying my working udev rule (/etc/udev/rules.d/10-local.rules):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw"

to this (end of row):

SUBSYSTEM=="tty", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", ATTRS{serial}=="000621000000", SYMLINK+="ttymkw", TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service"

I have user service offnet-uart-log.service in ~/.config/systemd/user, which I can manually trigger, but I don't get this far yet.

With the added , TAG+="systemd", SYSTEMD_WANTS="offnet-uart-log.service" at the end of my udev rule, the symlink is not created (I reload with sudo udevadm control --reload-rules && sudo udevadm trigger).

This tells me that the rule is wrong, but I don't know why. Could be related to udev being owned by root, while the service is owned by the user? Did I misunderstand WANTS?

I've tried all four combinations of SYSTEM_USER_WANTS or SYSTEM_WANTS, and = or +=. Removing the *_WANTS makes the symlink appear, so the error is in the *_WANTS.

How do I make my tty device trigger the log service?