wifi eth gprs 网络自动切换 脚本

#!/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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值