#! /bin/sh /&/& /sbin/telnetd ### Settings ### ssid='myssid' psk='mypassword' channel='6' ip='192.168.0.222' gateway='192.168.0.1' dns1='192.168.0.1' dns2='192.168.0.1' ### Firewall ### ifconfig eth1.2 192.168.200.1 brctl addif br5 eth1.3 cd /var/net_mgr/exec ./FirewallInit ./FirewallNone ### Catch Multiple Executions ### if [ -f /tmp/started ]; then exit 0; fi touch /tmp/started ### Housekeeping ### killall udhcpc killall pppoe-relay brctl delif br0 wl0 brctl delif br0 eth1.3 brctl delif br0 usb0 brctl delif br2 wl0.1 ifconfig br0 down ifconfig br1 down ifconfig br2 down ifconfig br3 down ifconfig br4 down ifconfig usb0 down ifconfig wl0.1 down echo "nameserver ${dns1}" > /var/etc/resolv.conf echo "nameserver ${dns2}" >> /var/etc/resolv.conf ### Wireless Client ### wl ap 0 wl wet 1 wl channel $channel wl scan wl scanresults ifconfig wl0 $ip killall nas nas -P /var/nas.sta.pid -H 34954 -i wl0 -S -m 4 -k $psk -s $ssid -w 2 -g 3600 > /dev/null 2>&1 & ### Set up bridge ### while [ $(ping -c 1 $gateway | grep -c "1 packets received") -eq 0 ]; do echo 1 > /dev/zero; done brctl addif br5 wl0 ifconfig wl0 0.0.0.0 up ifconfig eth1.3 0.0.0.0 up ifconfig br5 $ip up route add default gw $gateway br5 ### Keep Alive ### while [ $(ping -c 1 $gateway | grep -c "1 packets received") -eq 0 ]; do echo 1 > /dev/zero; done foo='$(' echo "while [ 1 ]; do if [ ${foo}ping -c 1 ${gateway} | grep -c '1 packets received') -eq 0 ]; then brctl delif br5 wl0 ifconfig br5 0.0.0.0 ifconfig wl0 ${ip} ping -q -c 2 ${ip} > /dev/zero ifconfig wl0 0.0.0.0 brctl addif br5 wl0 ifconfig br5 ${ip} route add default gw ${gateway} br5 ping -q -c 31 ${ip} > /dev/zero fi ping -q -c 2 ${ip} > /dev/zero #one second pause done" > /tmp/keepalive.sh sh /tmp/keepalive.sh & echo "HTTP/1.1 204 No Content Content-Length: 0 Connection: close " > /tmp/index.html echo "while [ 1 ]; do nc -l -p 1234 < /tmp/index.html | grep GET > /dev/ttyS0 done" > /tmp/serial.sh sh /tmp/serial.sh &