updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / cable-scripts / cable-status
blob7a11b0d6579d27ab93cbba9b17cce7c1fa525d17
1 #!/bin/bash
2 #Made by Marcelo A.
4 #***********************************************************************
6 # Defaults
7 CONFIG=/etc/ppp/pptp.conf
10 if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then
11 echo "$0: Cannot read configuration file '$CONFIG'" >& 2
12 exit 1
15 . $CONFIG
18 # If no PPPD_PIDFILE, something fishy!
19 if [ ! -r "/etc/ppp/ppp-cable.pid" ] && [ ! -r "/var/run/ppp-cable.pid" ] ; then
20 echo "cable-status: Link is down (can't read pppd PID file )"
21 exit 1
25 # Sigh. Some versions of pppd put PID files in /var/run; others put them
26 # in /etc/ppp. Since it's too messy to figure out what pppd does, we
27 # try both locations.
28 for i in /etc/ppp/ppp-cable.pid /var/run/ppp-cable.pid ; do
29 if [ -r $i ] ; then
30 IF=`tail -1 $i`
31 netstat -rn | grep "$IF" > /dev/null
32 /sbin/ifconfig $IF | grep "UP.*POINTOPOINT" > /dev/null
33 if [ "$?" != "0" ] ; then
34 echo "cable-status: Link is attached to $IF, but $IF is down"
35 exit 1
37 echo "cable-status: Link is up and running on interface $IF"
38 /sbin/ifconfig $IF
39 exit 0
42 done
44 echo "cable-status: Link is down"
45 exit 1