3g.usb 753 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. . /lib/functions.sh
  3. . /lib/netifd/netifd-proto.sh
  4. find_3g_iface() {
  5. local cfg="$1"
  6. local tty="$2"
  7. local proto
  8. config_get proto "$cfg" proto
  9. [ "$proto" = 3g ] || [ "$proto" = ncm ] || return 0
  10. # bypass state vars here because 00-netstate could clobber .device
  11. local dev=$(uci_get network "$cfg" device)
  12. if [ "${dev##*/}" = "${tty##*/}" ]; then
  13. if [ "$ACTION" = add ]; then
  14. proto_set_available "$cfg" 1
  15. fi
  16. if [ "$ACTION" = remove ]; then
  17. proto_set_available "$cfg" 0
  18. fi
  19. fi
  20. }
  21. [ "$ACTION" = add ] || [ "$ACTION" = remove ] || exit 0
  22. case "$DEVICENAME" in
  23. tty*)
  24. [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
  25. config_load network
  26. config_foreach find_3g_iface interface "/dev/$DEVICENAME"
  27. ;;
  28. esac