|
| 1 | +#!/bin/sh |
| 2 | +# --------------------------------------------------------- |
| 3 | +# 3G Connection Script for WiFi Pineapple. "Does the thing" |
| 4 | +# |
| 5 | +# Version: 2012-02-17 |
| 6 | +# Supports: |
| 7 | +# |
| 8 | +# ZTE MF591 (T-Mobile) -dkitchen |
| 9 | +# Novatel MC760 (Virgin) -dkitchen |
| 10 | +# Novatel MC760 (Ting) -dkitchen |
| 11 | +# Sierra 598u (Ting) -brianzimm |
| 12 | +# And more. |
| 13 | +# |
| 14 | +# Updates: wifipineapple.com |
| 15 | +# --------------------------------------------------------- |
| 16 | + |
| 17 | + |
| 18 | +# ----------------------------------------------------------- |
| 19 | +# Configure /etc/ppp/options with hard-coded working settings |
| 20 | +# ----------------------------------------------------------- |
| 21 | +echo " |
| 22 | +logfile /dev/null |
| 23 | +noaccomp |
| 24 | +nopcomp |
| 25 | +nocrtscts |
| 26 | +lock |
| 27 | +maxfail 0" > /etc/ppp/options |
| 28 | + |
| 29 | +# -------------------------------------------------------------------------------------------------- |
| 30 | +# Check for known usb modem vendor and product IDs then switch 'em from storage to serial modem mode |
| 31 | +# -------------------------------------------------------------------------------------------------- |
| 32 | +echo "Searching for attached 3G Modems" |
| 33 | +logger "3G: Connection Script here, searching for modems" |
| 34 | +MODEM=$(lsusb | awk '{ print $6 }') |
| 35 | +echo $MODEM |
| 36 | + |
| 37 | +case "$MODEM" in |
| 38 | + |
| 39 | +*19d2:1523*) echo "ZTE MF591 (T-Mobile) detected. Attempting mode switch" |
| 40 | + uci delete network.wan2 |
| 41 | + uci set network.wan2=interface |
| 42 | + uci set network.wan2.ifname=ppp0 |
| 43 | + uci set network.wan2.proto=3g |
| 44 | + uci set network.wan2.service=umts |
| 45 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 46 | + uci set network.wan2.apn=epc.tmobile.com |
| 47 | + uci set network.wan2.username=internet |
| 48 | + uci set network.wan2.password=internet |
| 49 | + uci set network.wan2.defaultroute=1 |
| 50 | + uci commit network |
| 51 | + usb_modeswitch -v 19d2 -p 1523 -V 19d2 -P 1525 -M 5553424312345678000000000000061b000000020000000000000000000000 -n 1 -s 20 |
| 52 | + sleep 10; rmmod usbserial |
| 53 | + sleep 3; insmod usbserial vendor=0x19d2 product=0x1525 |
| 54 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 55 | + logger "3G: firewall stopped" |
| 56 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 57 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 58 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 59 | + |
| 60 | + ;; |
| 61 | +*1410:6002* | *1410:5031*) echo "Novatel MC760 (Virgin Mobile) detected. Attempting mode switch" |
| 62 | + uci delete network.wan2 |
| 63 | + uci set network.wan2=interface |
| 64 | + uci set network.wan2.ifname=ppp0 |
| 65 | + uci set network.wan2.proto=3g |
| 66 | + uci set network.wan2.service=cdma |
| 67 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 68 | + uci set network.wan2.username=internet |
| 69 | + uci set network.wan2.password=internet |
| 70 | + uci set network.wan2.defaultroute=1 |
| 71 | + uci set network.wan2.ppp_redial=persist |
| 72 | + uci set network.wan2.peerdns=0 |
| 73 | + uci set network.wan2.dns=8.8.8.8 |
| 74 | + uci set network.wan2.keepalive=1 |
| 75 | + uci set network.wan2.pppd_options=debug |
| 76 | + uci set network.wan2.pppd_options=noauth |
| 77 | + uci commit network |
| 78 | + usb_modeswitch -v 1410 -p 5031 -V 1410 -P 6002 -M 5553424312345678000000000000061b000000020000000000000000000000 -n 1 -s 20 |
| 79 | + sleep 10; rmmod usbserial |
| 80 | + sleep 3; insmod usbserial vendor=0x1410 product=0x6002 |
| 81 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 82 | + logger "3G: firewall stopped" |
| 83 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 84 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 85 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 86 | + |
| 87 | + ;; |
| 88 | +*1410:5030*) echo "Novatel MC760 (Ting) detected. Attempting mode switch" |
| 89 | + uci delete network.wan2 |
| 90 | + uci set network.wan2=interface |
| 91 | + uci set network.wan2.ifname=ppp0 |
| 92 | + uci set network.wan2.proto=3g |
| 93 | + uci set network.wan2.service=cdma |
| 94 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 95 | + uci set network.wan2.username=internet |
| 96 | + uci set network.wan2.password=internet |
| 97 | + uci set network.wan2.defaultroute=1 |
| 98 | + uci set network.wan2.ppp_redial=persist |
| 99 | + uci set network.wan2.peerdns=0 |
| 100 | + uci set network.wan2.dns=8.8.8.8 |
| 101 | + uci set network.wan2.keepalive=1 |
| 102 | + uci set network.wan2.pppd_options=debug |
| 103 | + uci set network.wan2.pppd_options=noauth |
| 104 | + uci commit network |
| 105 | + usb_modeswitch -v 1410 -p 5030 -V 1410 -P 6000 -M 5553424312345678000000000000061b000000020000000000000000000000 -n 1 -s 20 |
| 106 | + sleep 10; rmmod usbserial |
| 107 | + sleep 3; insmod usbserial vendor=0x1410 product=0x6000 |
| 108 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 109 | + logger "3G: firewall stopped" |
| 110 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 111 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 112 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 113 | + |
| 114 | + ;; |
| 115 | +*1199:0025*) echo "Sierra 598u (Ting) detected. Attempting mode switch" |
| 116 | + uci delete network.wan2 |
| 117 | + uci set network.wan2=interface |
| 118 | + uci set network.wan2.ifname=ppp0 |
| 119 | + uci set network.wan2.proto=3g |
| 120 | + uci set network.wan2.service=cdma |
| 121 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 122 | + uci set network.wan2.username=internet |
| 123 | + uci set network.wan2.password=internet |
| 124 | + uci set network.wan2.defaultroute=1 |
| 125 | + uci set network.wan2.ppp_redial=persist |
| 126 | + uci set network.wan2.peerdns=0 |
| 127 | + uci set network.wan2.dns=8.8.8.8 |
| 128 | + uci set network.wan2.keepalive=1 |
| 129 | + uci set network.wan2.pppd_options=debug |
| 130 | + uci set network.wan2.pppd_options=noauth |
| 131 | + uci commit network |
| 132 | + usb_modeswitch -v 1199 -p 0025 |
| 133 | + sleep 10; rmmod usbserial |
| 134 | + sleep 3; insmod usbserial vendor=0x1199 product=0x0025 |
| 135 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 136 | + logger "3G: firewall stopped" |
| 137 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 138 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 139 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 140 | + |
| 141 | + ;; |
| 142 | +*12d1:1436*) echo "Huawei E173 detected. Attempting mode switch" |
| 143 | + uci delete network.wan2 |
| 144 | + uci set network.wan2=interface |
| 145 | + uci set network.wan2.ifname=ppp0 |
| 146 | + uci set network.wan2.proto=3g |
| 147 | + uci set network.wan2.service=umts |
| 148 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 149 | + uci set network.wan2.apn=apn |
| 150 | + uci set network.wan2.username=username |
| 151 | + uci set network.wan2.password=password |
| 152 | + uci set network.wan2.defaultroute=1 |
| 153 | + uci commit network |
| 154 | + usb_modeswitch -v 12d1 -p 1436 |
| 155 | + sleep 10; rmmod usbserial |
| 156 | + sleep 3; insmod usbserial vendor=0x12d1 product=0x1436 |
| 157 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 158 | + logger "3G: firewall stopped" |
| 159 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 160 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 161 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 162 | + |
| 163 | + ;; |
| 164 | +*12d1:140c*) echo "Huawei Modem (3-IRL) detected. Attempting mode switch" |
| 165 | + uci delete network.wan2 |
| 166 | + uci set network.wan2=interface |
| 167 | + uci set network.wan2.ifname=ppp0 |
| 168 | + uci set network.wan2.proto=3g |
| 169 | + uci set network.wan2.service=umts |
| 170 | + uci set network.wan2.device=/dev/ttyUSB0 |
| 171 | + uci set network.wan2.apn=3internet |
| 172 | + uci set network.wan2.username= |
| 173 | + uci set network.wan2.password= |
| 174 | + uci set network.wan2.defaultroute=1 |
| 175 | + uci commit network |
| 176 | + usb_modeswitch -v 12d1 -p 140c -V 12d1 -P 140c -M 5553424312345678000000000000061b000000020000000000000000000000 -n 1 -s 20 |
| 177 | + sleep 10; rmmod usbserial |
| 178 | + sleep 3; insmod usbserial vendor=0x12d1 product=0x140c |
| 179 | + sleep 5; /etc/init.d/firewall disable; /etc/init.d/firewall stop |
| 180 | + logger "3G: firewall stopped" |
| 181 | + iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o 3g-wan2 -j MASQUERADE |
| 182 | + iptables -A FORWARD -s 172.16.42.0/24 -o 3g-wan2 -j ACCEPT |
| 183 | + iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i 3g-wan2 -j ACCEPT |
| 184 | + |
| 185 | + ;; |
| 186 | +esac |
0 commit comments