conn

A script repository to manage connections in Linux.
git clone git://r-36.net/conn
Log | Files | Refs | README | LICENSE

ppp0-run.sh (1148B)


      1 #!/bin/sh
      2 
      3 . ../common.sh
      4 
      5 interface=`getinterface $0`
      6 
      7 case "$1" in
      8 	-s)
      9 		${WWANDIR}/gobi-x201-init -s
     10 		if [ ! $? -eq 0 ];
     11 		then
     12 			echo "Starting gobi failed. See syslog for errors."
     13 			exit 1
     14 		fi
     15 
     16 		echo -n "Waiting for $interface to exist ... "
     17 		ip link show $interface 2>&1 >/dev/null
     18 		i=0
     19 		while [ $? -gt 0 ];
     20 		do
     21 			i=`expr $i + 1`
     22 			if [ $i -gt 10 ];
     23 			then
     24 				echo "pppd is taking too long to setup" \
     25 					"$interface"
     26 				exit 1
     27 			fi
     28 			sleep 0.5
     29 			ip link show $interface 2>&1 >/dev/null
     30 		done
     31 		echo "done"
     32 
     33 		echo -n "Waiting for $interface to be online ..."
     34 		i=0
     35 		while [ -z "`ip addr show dev $interface 2>/dev/null \
     36 			| grep inet`" ];
     37 		do
     38 			i=`expr $i + 1`
     39 			if [ $i -gt 100 ];
     40 			then
     41 				echo "$interface is taking too long to" \
     42 					"get online"
     43 				exit 1
     44 			fi
     45 			sleep 0.5;
     46 			echo -n "."
     47 		done
     48 		echo "done"
     49 		startpingd $interface
     50 		exit $?
     51 		;;
     52 	-k)
     53 		stoppingd $interface
     54 		${WWANDIR}/gobi-x201-init -k
     55 		exit $?
     56 		;;
     57 	-o)
     58 		exit islinkup $interface
     59 		;;
     60 	-u)
     61 		break;
     62 		;;
     63 	-r)
     64 		$0 -k $interface;
     65 		$0 -s $interface;
     66 		;;
     67 	*)
     68 		echo "usage: $0 [-s|-k|-u|-r] interface"
     69 		exit 1
     70 		;;
     71 esac
     72 exit 0
     73