2012/11/18 Warpme <span dir="ltr"><<a href="mailto:warpme@o2.pl" target="_blank">warpme@o2.pl</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well,<br>
Things pretend to be simple seems to be not simple<br>
After 2 days of fighting with issue I have to ask for help.<br>
I want to kick systemd service when usb HDD is plugged.<br>
As started service needs to know HDD label I wan to use templates.<br>
Here is what it goes:<br>
<br>
udev rule:<br>
SUBSYSTEM=="block", KERNEL=="sd[c-z][0-9]", GOTO="begin"<br>
GOTO="end"<br>
LABEL="begin"<br>
ACTION=="add", GOTO="begin_add"<br>
ACTION=="remove", GOTO="begin_remove"<br>
GOTO="end"<br>
<br>
LABEL="begin_add"<br>
SYMLINK+="usbhd-%k", GROUP="root"<br>
ENV{ID_FS_LABEL_ENC}="usbhd-%<u></u>k"<br>
IMPORT{program}="/sbin/blkid -o udev -p $tempnode"<br>
ENV{ID_FS_LABEL_ENC}==".myth.<u></u>backup", ENV{MOUNT_DIR}="/media/$env{<u></u>ID_FS_LABEL_ENC}", RUN+="/bin/mkdir -p $env{MOUNT_DIR}", RUN+="/bin/mount -t auto -o rw,noauto,noatime /dev/%k $env{MOUNT_DIR}"<br>
ENV{ID_FS_LABEL_ENC}==".myth.<u></u>backup", TAG+="systemd", ENV{SYSTEMD_WANTS}="ext-usb-<u></u>backup.service"<br>
GOTO="end"<br>
<br>
<br>
<br>
service file:<br>
[Unit]<br>
Description=MythtTV ExtUSB Backup Helper<br>
<br>
[Service]<br>
ExecStart=/usr/local/bin/run-<u></u>backup.sh<br>
Type=forking<br>
GuessMainPID=false<br>
RemainAfterExit=no<br>
<br>
<br>
<br>
Issue:<br>
it works with:<br>
ENV{ID_FS_LABEL_ENC}==".myth.<u></u>backup", RUN+="/usr/bin/systemctl start ext-usb-backup.service"<br>
<br>
but not works with:<br>
ENV{ID_FS_LABEL_ENC}==".myth.<u></u>backup", TAG+="systemd", ENV{SYSTEMD_WANTS}="ext-usb-<u></u>backup.service"<br>
<br>
(With TAG+ENV approach udev behaves like line with TAG+ENV is<br>
non-existing: no any error nor any sign it is parsed)<br>
<br>
Where the issue is ?<br>
<br>
Thx in advance !<br></blockquote><div> Hi</div><div><br></div><div>I don't really have an idea, but here are some things you could check additionally:</div><div>Does systemd create a .device unit? And if yes is it active/plugged? And does it have the correct "Wants=ext-usb-backup.service" attribute? Does udevadm info --query=property --path=<path to sysfs device> show the correct values for</div>
<div>SYSTEMD_WANTS and TAGS?</div></div><br><div>Mirco</div>