This might be a bit late, but I wanted to do exactly the same -- performing some action when a USB device is added/removed.
The following example code will automatically configure a Huawei E169 UMTS modem and connect to 3G as soon as its plugged in or the system is rebooted.
Code was tested briefly using Kamikaze 8.09.1 on a NSLU2. Feel free to improve it!
Contents of /etc/hotplug.d/usb/20-usb-huawei-e169:
#!/bin/sh
# the product string for the Huawei E169
HUAWEI_E169="12d1/1001/0"
# the target we are looking for
TARGET_PRODUCT=${HUAWEI_E169}
case "$ACTION" in
add)
[ ${PRODUCT} == ${TARGET_PRODUCT} ] &&
[ -n "${INTERFACE}" ] &&
[ "$(expr substr ${INTERFACE} 1 2)" == "8/" ] && {
if [ "$(lsusb -d 12d1:1001 -v | grep bNumInterfaces | cut -c 29)" == "1" ]
then
# invoke usb_modeswitch
logger "Switching UMTS modem..."
switch_huawei.sh
else
# configure /dev/ttyUSB0 and bring up the wan interface
logger "Connecting via UMTS..."
settty.sh
ifup wan
fi
}
;;
esac
(Last edited by bosterm on 21 Jan 2010, 13:54)