I want to automatically attach any inserted usb drive to a virtual machine that is run inside ubuntu under particular user login.
To do that, I've set up the following udev rule(from [1], [2]):
KERNEL=="sd?", ENV{ID_BUS}=="usb", SUBSYSTEM=="block", RUN+="/bin/su me -c '/home/me/automout.sh'"
To test udev working, the automount.sh script was done as following:
#!/bin/bash
echo "$devpath">/home/me/2
When run manually, the empty file is created inside home, but when a usb is inserted, nothing happens. What may be the cause of that?
Indeed, as MiiinimalLogic suggested, the problem was owner of the script.
If you want to run a script as another user via su, the script should belong to root.
The file may still reside in user's home.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With