I'm trying to write a simple systemd
service that gets started when I insert a DVD into my DVD-ROM drive. However, my service never starts even though I see the relevant SYSTEMD_WANTS
while running udevadm monitor --env
. I can start the service manually and it works as expected.
Here's what I have:
/etc/systemd/system/test.service
:
[Unit]
Description=just touch /tmp/pizza
[Service]
Type=oneshot
ExecStart=/usr/sbin/touch /tmp/pizza
RemainAfterExit=yes
ExecStop=/usr/sbin/rm -v /tmp/pizza
/etc/udev/rules.d/98-dd-one-from-udev.rules
:
KERNEL=="sr[0-9]*", ENV{DEVTYPE}=="disk", TAG+="systemd", ENV{SYSTEMD_WANTS}+="test.service"
When I start my service manually with sudo systemctl start test.service
I see the file /tmp/pizza
show up, as well as the expected happy things in journalctl
.
When I monitor the output of udevadm monitor --env
I see that my SYSTEMD_WANTS
environment variable is being set as expected:
...
ID_SERIAL=MATSHITA_UJDA750_DVD_CDRW-0:0
ID_TYPE=cd
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=MATSHITA
ID_VENDOR_ENC=MATSHITA
ID_VENDOR_ID=05e3
MAJOR=11
MINOR=1
SEQNUM=1822
SUBSYSTEM=block
SYSTEMD_WANTS=test.service <--- Woohoo!
TAGS=:seat:systemd:uaccess:
USEC_INITIALIZED=6417
And yet, my service never starts...
What linkage am I missing here?
For what it's worth, I'm running Arch Linux with systemd
version 218.