您的位置:首页 > 理论基础 > 计算机网络

wifi eth gprs 网络自动切换 脚本

2016-07-06 21:11 567 查看
#!/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: