0

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?

1
  • Being a "specific usb stick" I suspect you already know the value %k will take on in your udev rule. If that's the case, why not have new.service depend on that specific instance? I.e. [email protected] Commented Oct 15 at 6:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.