--- net.wvdial.old 2004-08-01 01:56:11.700451152 -0400 +++ net.wvdial 2004-08-01 01:42:34.779641992 -0400 @@ -1,15 +1,17 @@ #!/sbin/runscript # -# $Id: net.wvdial,v 1.3 2004/07/27 18:35:08 rouslan Exp $ +# $Id: net.wvdial,v 1.6 2004/08/01 05:42:34 rouslan Exp $ # depend() { - need slmodem + if [ "$SLMODEM" == "yes" ] + then + need slmodem + fi } checkinstalled() { - PATH=/bin:/usr/bin:/sbin:/usr/sbin which wvdial >/dev/null - if [ $? != 0 ] + if [ ! -e /usr/bin/wvdial ] then eerror "Please install wvdial." return 1 @@ -17,8 +19,7 @@ } checkconfigured() { - PATH=/bin:/usr/bin:/sbin:/usr/sbin find /etc/wvdial.conf >/dev/null - if [ $? != 0 ] + if [ ! -e /etc/wvdial.conf ] then eerror "Configaration file /etc/wvdial.conf is missing." eerror "Please run \"wvdialconf\" to configure wvdial." @@ -42,27 +43,53 @@ } checkstarted() { - PATH=/bin:/usr/bin:/sbin:/usr/sbin ifconfig | grep ppp >/dev/null - eend $? + PATH=/sbin:/usr/sbin:/bin:/usr/bin ifconfig | grep ppp >/dev/null + return $? } start() { + ebegin "Starting wvdial" + checkall || return 1 - ebegin "Starting wvdial" + start-stop-daemon --start --quiet --background --exec /usr/bin/wvdial -- "$OPTIONS" - start-stop-daemon --start --quiet --background --exec /usr/bin/wvdial \ - -- "$OPTIONS" # Because of "background" option, we cannot get a return status of - # wvdial. It usually starts in about 30 to 40 seconds. - sleep 40 - checkstarted + # wvdial. It usually starts in no more than 60 seconds. + echo -ne "\e[A\e[43G" + for ((i=0,status=1; status!=0 && i<30; ++i)) + do + sleep 2 + echo -n "." + checkstarted && status=0 + done + echo + if [ "$status" -eq 0 ] + then + eend 0 + else + eerror "Wvdial timed out" + eend 1 + fi } stop() { ebegin "Stopping wvdial" start-stop-daemon --stop --quiet --exec /usr/bin/wvdial - eend $? # It takes a few seconds for wvdial to disconnect. - sleep 5 + echo -ne "\e[A\e[43G" + for ((i=0,status=1; status!=0 && i<10; ++i)) + do + sleep 1 + echo -n "." + checkstarted || status=0 + done + echo + if [ "$status" -eq 0 ] + then + eend 0 + else + eerror "Failed to stop wvdial" + eend 1 + fi }