I have a udev rule which looks for a specific usb stick (VID and PID), and then starts a templated systemd service:
KERNEL=="sd[a-z][0-9]", ... ACTION=="add", RUN+="/bin/systemctl start usb-mount@%k.service"
KERNEL=="sd[a-z][0-9]", ... ACTION=="change|remove", RUN+="/bin/systemctl stop usb-mount@%k.service"
[email protected] does some checking of the contents of the usb stick before setting up the final mount point.
I now want another systemd service, new.service say, to be started when the usb stick is successfully mounted, and stopped when it is unmounted. For a non-templated service, I could simply let new.service depend on it using Requires= and After=, but that is not possible for templates (see e.g. https://stackoverflow.com/questions/36418331/require-any-instance-of-a-template).
So how can I achieve what I want? Is there a way of creating a "state" from [email protected] which new.service can depend on?
%kwill take on in your udev rule. If that's the case, why not havenew.servicedepend on that specific instance? I.e.[email protected]