继续继续。。。
代码: 全选
#!/bin/sh
#a=on建立拨号/a=off断开连接
a=0
b=`ifconfig |grep ppp|wc -l`
#配置账号
#if(zenity --question --text="配置账号密码?")then
#sudo pppoeconf
#判断连接是否建立
if [ $b != 0 ];then
if(zenity --question --text="断开连接?")then a=off
fi
else a=on
while [ ture ];do
w=`route -n|grep -c wlan0`
if [ $w != 0 ];then echo "use wlan0";break;fi
e=`route -n|grep -c eth0`
if [ $e != 0 ];then echo "use eth0";break;fi
echo "no lan...wating"
sleep 2 & while [ -e /proc/$! ];do echo -n '.';sleep 1;done
done
fi
if [ $a = on ];then
#重试次数t
t=0
i=0
while [ ture ];do
i=$(($i + 1))
#尝试建立连接
if [ $w != 0 ];then
echo 第$i次拨号。。。wlan0
pon dsl-provider-wlan0
elif [ $e != 0 ];then
echo 第$i次拨号。。。eth0
pon dsl-provider-eth0
fi
sleep 0.1
if [ $i = $t ];then
if(zenity --question --text="超过重试$t次数是否继续?")then
i=1
fi
fi
#判断连接是否建立
b=`ifconfig |grep ppp|wc -l`
if [ $b != 0 ];then
echo "已连接"
exit
fi
sleep 2.9&while [ -e /proc/$! ];do echo -n '.';sleep 1;done
done
elif [ $a = off ];then
#断开连接
poff -a
b=`ifconfig |grep ppp|wc -l`
if [ $b = 0 ];then
echo "已断开"
exit
else
zenity --info --text="断开失败"
fi
fi
exit