On 11/25/12 1:24 PM, Andrey Borzenkov wrote:
В Fri, 16 Nov 2012 17:37:27 +0100
Warpme <war...@o2.pl> пишет:

[Service]
ExecStart=/usr/local/bin/run-backup.sh
Type=forking
GuessMainPID=false
RemainAfterExit=no



Issue:
it works with:
ENV{ID_FS_LABEL_ENC}==".myth.backup", RUN+="/usr/bin/systemctl start
ext-usb-backup.service"

Is your actual backup program started in background by run-backup.sh
and script itself exits? Because that is what is implied by
Type=forking. If yes, it apparently takes over 30 seconds as systemctl
is killed by udev. You probably want to use "systemctl --no-block" in
this case.
Andrey,
Thx for Your post.
Indeed forking is bad idea. I changed it to oneshot and it works OK.

but not works with:
ENV{ID_FS_LABEL_ENC}==".myth.backup", TAG+="systemd",
ENV{SYSTEMD_WANTS}="ext-usb-backup.service"

Hard to tell without systemd debug output. You can enable it online by
sending signal to systemd, see man page.

I found issue: when developing udev rule I tested it via:

udevadm trigger --sysname-match=sdc1 --action=add

This seems to correctly launch actions within udev but NOT in systemd.
However, when I physically connect USB device it works.

Also I have another interesting observation:

My udev rule has:

TAG+="systemd", ENV{SYSTEMD_WANTS}+="ext-usb-backup@$env{ID_FS_LABEL_ENC}\x20connected.service"

My unit has something like this:

ExecStart=/bin/sh -c "/usr/bin/perl /usr/local/bin/osd_notify.pl %I connected backup"

So for HDD with label ".myth.backup", osd_notify.pl should have parameters like: ".myth.backup connected backup"

but in reality it has: "sys/devices/pci0000:00/0000:00:09.0/0000:04:00.0/usb3/3-1/3-1:1.0/host12/target12:0:0/12:0:0:0/block/sdc/sdc1 connected backup"

but when I change rule to:

TAG+="systemd", ENV{SYSTEMD_WANTS}+="ext-usb-backup@\x20$env{ID_FS_LABEL_ENC}\x20connected.service"

it think it is result of bug in systemd....

<<attachment: warpme.vcf>>

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to