comgt: handle ttyHS* devices in usb hotplug, fix typo (#9046)
[openwrt/openwrt.git] / package / comgt / files / 3g.usb
1 #!/bin/sh
2
3 . /etc/functions.sh
4
5 log() {
6 logger -t 3g-hotplug "$@"
7 }
8
9 find_3g_iface() {
10 local cfg="$1"
11 local tty="$2"
12
13 local proto
14 config_get proto "$cfg" proto
15
16 [ "$proto" = 3g ] && {
17 local auto
18 config_get_bool auto "$cfg" auto 1
19 [ "$auto" = 1 ] || return 0
20
21 local dev
22 config_get dev "$cfg" device
23
24 if [ "${dev##*/}" = "${tty##*/}" ]; then
25 log "Starting interface $cfg for device ${tty##*/}"
26 ( sleep 1; /sbin/ifup "$cfg" ) &
27 fi
28 }
29 }
30
31
32 if [ "$ACTION" = add ]; then
33 case "$DEVICENAME" in
34 *-*:*.*) config_load network;;
35 *) exit 0;;
36 esac
37
38 local tty
39 for tty in /sys/$DEVPATH/ttyUSB* /sys/$DEVPATH/tty/ttyACM* /sys/$DEVPATH/tty/ttyHS*; do
40 [ -d "$tty" ] || continue
41 config_foreach find_3g_iface interface "$tty"
42 done
43 fi