15

I can write unit files, which depend on a mount, because I can list them and then add to Requires=xxx, such as:

# systemctl list-units | grep data
mount-data.service    loaded active exited    Manage the data partition

What I am trying to do is to make service start when webcam is plugged into device. systemctl list-units | grep video0 returns nothing. Can someone explain me in simple terms, what do I do to ensure that? What I do want to happen is start service when /dev/video0, /dev/video1, etc appear.

I got a clue from this post, that I will need to write a udev rule, but I have no idea what exactly needs to be done here. Help?

1 Answer 1

16

I figured this out. First, add following line(s) to one of the files in udev rule folder, I used /lib/udev/rules.d/99-systemd.rules

KERNEL=="video0", SYMLINK="video0", TAG+="systemd"
KERNEL=="video1", SYMLINK="video1", TAG+="systemd"

Then you can bind to video device(s) in service unit file:

[Unit]
BindsTo=dev-video0.device
After=dev-video0.device
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .