ipq806x: rt4230w-rev6: fix status reporting via the LEDs
[openwrt/openwrt.git] / package / network / utils / comgt / files / 3g.usb
1 #!/bin/sh
2 . /lib/functions.sh
3 . /lib/netifd/netifd-proto.sh
4
5 find_3g_iface() {
6 local cfg="$1"
7 local tty="$2"
8
9 local proto
10 config_get proto "$cfg" proto
11 [ "$proto" = 3g ] || [ "$proto" = ncm ] || return 0
12
13 # bypass state vars here because 00-netstate could clobber .device
14 local dev=$(uci_get network "$cfg" device)
15
16 if [ "${dev##*/}" = "${tty##*/}" ]; then
17 if [ "$ACTION" = add ]; then
18 proto_set_available "$cfg" 1
19 fi
20 if [ "$ACTION" = remove ]; then
21 proto_set_available "$cfg" 0
22 fi
23 fi
24 }
25
26 [ "$ACTION" = add ] || [ "$ACTION" = remove ] || exit 0
27
28 case "$DEVICENAME" in
29 tty*)
30 [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
31 config_load network
32 config_foreach find_3g_iface interface "/dev/$DEVICENAME"
33 ;;
34 esac
35