Creating a correct path for $REMOVER only works correctly while
"add" event.
On event "remove" the use of readlink does not return a path
because it is not listed in /sys/devices/.... anymore - the device is
already unplugged.
This causes that the $REMOVER variable is just filled with
"/var/run/usb/" and the script cannot be executed.
You should use another method to avoid such things like
"/sys/devices//usb"
$DEVPATH is still valid at this point.
I think filling the variable $REMOVER with
REMOVER=/var/run/usb/$(echo "$SYSFS$DEVPATH" | sed -e 's;/;
%;g')
should work. Note the missing "/" between $SYSFS and $DEVFS.
Below is a working sample:
#
# declare a REMOVER name that the add action can use to create a
# remover, or that the remove action can use to execute a remover.
#
if [ "$DEVPATH" != "" ]; then
# probably, 2.6.x
sed -e 's;/;%;g'"
REMOVER=/var/run/usb/$(echo "$SYSFS$DEVPATH" | sed -e 's;/;
%;g')
elif [ "$DEVICE" != "" ]; then
# 2.4.x?
REMOVER=/var/run/usb/$(echo $DEVICE | sed -e 's;/;%;g')
else
# should not happen?
REMOVER=/var/run/usb/$(echo "$INTERFACE/$PRODUCT/$TYPE"
| sed -e 's;/;%;g')
fi
export REMOVER
a working usb.agent