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
#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
相关文章推荐
- 通过HttpServletRequest获取上一个页面
- HTTP中GET和POST的区别
- tensorflow入门简单卷积神经网络
- 高性能HTTP加速器Varnish安装与配置
- HTTP协议
- httpClient
- 计算机网络核心原理-授课用
- tcping
- 网络爬虫基本原理
- [转]www-authenticate认证过程浅析
- 计算机网络——基于socket的网络应用
- AJAX入门 之 XMLHttpRequest对象的属性(一)
- 网络通讯选择TCP或UDP的指导方针
- 关于HTTP中GET,POST,PUT,DELETE的区别。
- 远程计算机需要网络级别身份验证
- 关于TCP和UDP的端口介绍
- UNIX网络编程——I/O复用(select、poll)
- httpClient 接口调用
- http状态码
- tomcat配置https方法