Advertisement
Guest User

Untitled

a guest
May 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. set_3g_led() {
  2. # set on WRT54G3G only
  3. [ -d /proc/diag ] || return 0
  4. grep WRT54G3G /proc/diag/model >/dev/null || return 0
  5. echo "$1" > /proc/diag/led/3g_green
  6. echo "$2" > /proc/diag/led/3g_blue
  7. echo "$3" > /proc/diag/led/3g_blink
  8. }
  9.  
  10. scan_3g() {
  11. local device
  12.  
  13. scan_ppp "$@"
  14. config_get device "$1" device
  15.  
  16. # enable 3G with the 3G button by default
  17. config_get button "$1" button
  18. [ -z "$button" ] && {
  19. config_set "$1" button 1
  20. }
  21. }
  22.  
  23. stop_interface_3g() {
  24. set_3g_led 0 0 0
  25. }
  26.  
  27. setup_interface_3g() {
  28. local iface="$1"
  29. local config="$2"
  30.  
  31. config_get device "$config" device
  32. config_get maxwait "$config" maxwait
  33. maxwait=${maxwait:-20}
  34. while [ ! -e "$device" -a $maxwait -gt 0 ];do # wait for driver loading to catch up
  35. maxwait=$(($maxwait - 1))
  36. sleep 1
  37. done
  38.  
  39. config_get apn "$config" apn
  40. config_get service "$config" service
  41. config_get pincode "$config" pincode
  42. config_get mtu "$config" mtu
  43. config_get password "$config" password
  44. config_get username "$config" username
  45.  
  46. case "$service" in
  47. cdma|gprs*) ledcode="1 0";;
  48. evdo|umts*) ledcode="0 1";;
  49. *) ledcode="0 0";; #shouldn't happen
  50. esac
  51.  
  52. set_3g_led $ledcode 1
  53.  
  54. #Check to see if it is an HSO or a regular USB device
  55. if grep "Vendor=0af0" < /proc/bus/usb/devices 2>&- >&- ; then
  56.  
  57. for module in rfkill hso; do
  58. /sbin/insmod $module 2>&- >&-
  59. done
  60.  
  61. RESOLV_CONF="/tmp/resolv.conf.auto"
  62. DATA=$(USE_PASS="$password" USE_USER="$username" USE_APN="$apn" SERVICE="$service" PINCODE="$pincode" /usr/bin/gcom -d "$device" -s /etc/gcom/hso-connect.gcom)
  63. DATA=$(echo $DATA | tr -d " " | grep -v ^$)
  64. IP=$(echo $DATA | cut -d , -f 2)
  65. NS1=$(echo $DATA | cut -d , -f 4)
  66. NS2=$(echo $DATA | cut -d , -f 5)
  67. ifconfig hso0 $IP netmask 255.255.255.255 up
  68. route add default dev hso0
  69. echo "#Configured by HSO" > $RESOLV_CONF
  70. [ -n "$NS1" ] && echo "nameserver $NS1" >> $RESOLV_CONF
  71. [ -n "$NS2" ] && echo "nameserver $NS2" >> $RESOLV_CONF
  72. env -i ACTION="ifup" INTERFACE="wan" DEVICE="hso0" PROTO=hso /sbin/hotplug-call "iface"
  73.  
  74. else
  75.  
  76. for module in usbserial option crc-ccitt slhc ppp_generic ppp_async; do
  77. /sbin/insmod $module 2>&- >&-
  78. done
  79.  
  80. config_set "$config" "connect" "USE_APN=$apn SERVICE=$service PINCODE=$pincode /usr/bin/gcom -s -d $device /etc/gcom/3g.gcom"
  81. start_pppd "$config" \
  82. novj \
  83. nobsdcomp \
  84. noauth \
  85. crtscts \
  86. updetach \
  87. ${mtu:+mtu $mtu mru $mtu} \
  88. 460800 "$device"
  89. fi
  90.  
  91. set_3g_led $ledcode 0
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement