#!/bin/sh
#file name is gwInit.sh
kill -9 `'ps' -ef | 'grep' udhcpc | 'awk' '{print $1}'`
kill -9 `'ps' -ef | 'grep' gwdev | 'awk' '{print $1}'`
kill -9 `'ps' -ef | 'grep' wpa_supplicant.supplicant | 'awk' '{print $1}'`
# huawei 4G mode config
if test "$1" == "gprs"; then
echo "12d1 15c1" > /sys/bus/usb-serial/drivers/generic/new_id
ifconfig eth0 down
ifconfig eth1 down
ifconfig wlan0 down
pppd call gprs
sleep 20s
# wifi 2.4G mode config
elif test "$1" == "wifi"; then
ifconfig eth0 down
ifconfig eth1 down
ifconfig wlan0 down
insmod /mnt/wifi-drv/8192cu.ko
ifconfig wlan0 up
sleep 1s
sed '8c \ ssid="'$2'"' /etc/wpa_supplicant.conf -i
sed '9c \ psk="'$3'"' /etc/wpa_supplicant.conf -i
/mnt/wifi-drv/wpa_supplicant.supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -B
udhcpc -i wlan0 &
sleep 3s
#eth0 100M config
elif test "$1" == "eth0"; then
ifconfig eth1 down
ifconfig wlan0 down
udhcpc -i eth0 &
#ceshi
#eth1 100M config
elif test "$1" == "eth1"; then
ifconfig eth0 down
ifconfig wlan0 down
udhcpc -i eth1 &
else
echo $1
fi
# net config end
#gatway start...
cd /mnt/gw-bin
mv gwdev.bin gwdev
chmod +x gwdev
#./gwdev
#file name is gwInit.sh
kill -9 `'ps' -ef | 'grep' udhcpc | 'awk' '{print $1}'`
kill -9 `'ps' -ef | 'grep' gwdev | 'awk' '{print $1}'`
kill -9 `'ps' -ef | 'grep' wpa_supplicant.supplicant | 'awk' '{print $1}'`
# huawei 4G mode config
if test "$1" == "gprs"; then
echo "12d1 15c1" > /sys/bus/usb-serial/drivers/generic/new_id
ifconfig eth0 down
ifconfig eth1 down
ifconfig wlan0 down
pppd call gprs
sleep 20s
# wifi 2.4G mode config
elif test "$1" == "wifi"; then
ifconfig eth0 down
ifconfig eth1 down
ifconfig wlan0 down
insmod /mnt/wifi-drv/8192cu.ko
ifconfig wlan0 up
sleep 1s
sed '8c \ ssid="'$2'"' /etc/wpa_supplicant.conf -i
sed '9c \ psk="'$3'"' /etc/wpa_supplicant.conf -i
/mnt/wifi-drv/wpa_supplicant.supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -B
udhcpc -i wlan0 &
sleep 3s
#eth0 100M config
elif test "$1" == "eth0"; then
ifconfig eth1 down
ifconfig wlan0 down
udhcpc -i eth0 &
#ceshi
#eth1 100M config
elif test "$1" == "eth1"; then
ifconfig eth0 down
ifconfig wlan0 down
udhcpc -i eth1 &
else
echo $1
fi
# net config end
#gatway start...
cd /mnt/gw-bin
mv gwdev.bin gwdev
chmod +x gwdev
#./gwdev