(Fedora 4... don't hassle me... :-P)
Here is my working udev rule for addition:
Code:
ACTION=="add", KERNEL=="sd??", BUS=="usb", DRIVER=="usb-storage", NAME="usb-%k", SYMLINK="usb/%k"
ACTION=="add", KERNEL=="sd??", BUS=="usb", DRIVER=="usb-storage", RUN+="/bin/mkdir -p /media/usb/%k"
ACTION=="add", KERNEL=="sd??", BUS=="usb", DRIVER=="usb-storage", RUN+="/bin/mount /dev/usb-%k /media/usb/%k", OPTIONS="last_rule"
And here was my first (ideal = no scripts involved) attempt for removal:
Code:
ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/usb-sd*", RUN+="/bin/umount $(/bin/mount|/bin/grep ${DEVNAME}|/bin/awk '{print $3}')"
And after that failed, I tried to get something working with a script:
Code:
ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/usb-sd*", PROGRAM="/etc/udev/scripts/usbdrive.sh", RUN+="/bin/umount %c"
And the script:
Code:
#!/bin/sh
# Get the mount entry for ${DEVNAME}
MOUNT=`/bin/mount|/bin/grep ${DEVNAME}|/bin/awk '{print $3}'`
[ $? -eq 0 ] && echo $MOUNT || exit 1
According to the man-page, I should have $DEVNAME available for use in both "RUN" and "PROGRAM". None of these have worked though, leaving my usb-mount there.
The idea here is to NOT have to offshoot the work to a script (aka. my first attempt)... which is why I am getting into trouble.
Any help on what I am doing wrong?
Is inline bash just not allowed?