updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / cable-scripts / cable-stop
blobde0c1aab5db10aa8a8127b303180808b26824015
1 #!/bin/bash
2 #Made by Marcelo A.
4 # Set to "C" locale so we can parse messages from commands
5 LANG=C
6 export LANG
7 # Must be root
8 if test "`id -u`" != 0 ; then
9 echo "$0: You must be root to run this script" >& 2
10 exit 1
13 ME="`basename $0`"
15 CONFIG=/etc/ppp/pptp.conf
17 if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then
18 echo "$ME: Cannot read configuration file '$CONFIG'" >& 2
19 exit 1
22 . $CONFIG
24 # Ignore SIGTERM
25 trap "" 15
27 for i in /etc/ppp/ppp-cable.pid /var/run/ppp-cable.pid ; do
28 if [ -r $i ] ; then
29 PID=`head -n1 $i`
30 #Check if still running
31 kill -0 $PID > /dev/null 2>&1
32 if [ $? != 0 ] ; then
33 echo "$ME: Connection appears to have died (PID $PID)" >& 2
34 else
35 #Kill pppd , which should in turn kill pptp
36 logger -p daemon.notice "Terminating cable-ppp link"
37 echo "Terminating cable-ppp link on pid ($PID),please wait.."
38 kill $PID > /dev/null 2>&1
39 sleep 4
41 exit 0
42 fi
43 done
45 echo "No active cable connection found"
47 exit 0