OpenWrt Forum Archive

Topic: Hotplug2 help

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've got Kamikaze running on an Airlink ar360w3g which supports USB and PCMCIA 3g modems. I have everything working great, but I'd like to do a few things (link /dev/ttyUSB0 or USB1 to /dev/modem, configure some firewall stuff, and dial out) when a modem is inserted.

I've read through hotplug2 documentation (which is pretty thin) and I'm not sure how do create a rule for this type of device.
Any help is appreciated smile

(Last edited by aport on 26 Nov 2008, 01:02)

bump smile

I am using comgt as my manager and dialer. It seems to work very well. However, my ultimate goal is to call comgt when a card is inserted. I don't think the 3g-iface script can do that.

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:


# the product string for the Huawei E169

# the target we are looking for

case "$ACTION" in

        [ ${PRODUCT} == ${TARGET_PRODUCT} ] &&
        [ -n "${INTERFACE}" ] &&
        [ "$(expr substr ${INTERFACE} 1 2)" == "8/" ] && {
            if [ "$(lsusb -d 12d1:1001 -v | grep bNumInterfaces | cut -c 29)" == "1" ]
                # invoke usb_modeswitch
                logger "Switching UMTS modem..."
                # configure /dev/ttyUSB0 and bring up the wan interface
                logger "Connecting via UMTS..."
                ifup wan

(Last edited by bosterm on 21 Jan 2010, 14:54)

bosterm: thanks!

I actually added a rule /etc/hotplug2-common.rules to launch a little connection manager. It does pretty much the same as your script but it's in C.

here's the rule if anyone cares:

SUBSYSTEM == usb-serial, DEVICENAME ~~ (ttyUSB0) {
        exec /bin/manager;           

The discussion might have continued from here.