3

udev does not run my bash script properly.

Heres my rule:

ACTION=="add", KERNEL=="sd*1", SUBSYSTEM=="block", ATTRS{idVendor}=="0930", ATTRS{idProduct}=="6544", RUN="/usr/local/bin/usb-bmw-in"    
ACTION=="remove", KERNEL=="sd*1", SUBSYSTEM=="block", ATTRS{idVendor}=="0930", ATTRS{idProduct}=="6544", RUN="/usr/local/bin/usb-bmw-out"

And here is the script that gets executed:

#!/bin/bash
echo timer > /sys/class/leds/led1/trigger
rsync --delete-after -c --preallocate -r /media/NAS/Sync/Musik/BMW/ /media/24366EC6366E9916/
umount /dev/sdc1
echo default-on > /sys/class/leds/led0/trigger
echo none > /sys/class/leds/led1/trigger

The script should light up a red led, indicating that its working. Then it should copy my car playlist to the usb stick and unmount the device.

When it's done, it should light up a green led and turn off the red one.

The red led lights up properly, the rsync command gets fired as well, but thats it. The red LED is still on, the device is still mounted and the green led hasnt been turned on.

When I run the script manually its working fine.

Unkn0wn
  • 97
  • 1
  • 6

1 Answers1

1

Actually made it working by moving the two echo command at the bottom above the umount command and relaunched the script in a background shell with setsid as explained by the user "Alives" on stackexchange:

https://unix.stackexchange.com/a/79545

Community
  • 1
  • 1
Unkn0wn
  • 97
  • 1
  • 6