]> git.pld-linux.org Git - projects/rc-scripts.git/blob - sysconfig/network-scripts/ifdown-ppp
Synced with latest from old repo
[projects/rc-scripts.git] / sysconfig / network-scripts / ifdown-ppp
1 #!/bin/sh
2 PATH=/sbin:/usr/sbin:/bin:/usr/bin
3
4 cd /etc/sysconfig/network-scripts
5 . /etc/rc.d/init.d/functions.network
6
7 CONFIG=$1
8 source_config
9
10 if [ ! -f /var/run/ppp-$DEVICE.dev ]; then
11     # ppp isn't running, or we didn't start it
12     exit 0
13 fi
14
15 file=/var/run/`cat /var/run/ppp-$DEVICE.dev`.pid
16
17 # signals ifup-ppp not to persist -- must do this before exiting if PPP
18 # has not yet started ($file does not exist).
19 rm -f /var/run/ppp-$DEVICE.dev
20
21 if [ ! -f $file ]; then
22     exit 0
23 fi
24
25 PID=`cat $file`
26 if [ -z "$PID" ]; then
27   exit 1
28 fi
29
30 # pppd might have chat as a child; remember chat's pid to kill after pppd.
31 # (After, not before, so that pppd doesn't just restart it).
32
33 CHATPID=`ps axl | awk '$4 ~ $PID {print $3}' 2>/dev/null`
34
35 kill $PID > /dev/null 2>&1
36 [ -n "$CHATPID" ] && kill $CHATPID > /dev/null 2>&1
37 if [ ! -d /proc/$PID ]; then
38   /etc/sysconfig/network-scripts/ifdown-post $1
39   exit 0
40 fi
41 sleep 2
42 if [ ! -d /proc/$PID ]; then
43   /etc/sysconfig/network-scripts/ifdown-post $1
44   exit 0
45 fi
46
47 kill -KILL $PID > /dev/null 2>&1
48 if [ -d /proc/$PID ]; then
49   logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" &
50 else
51   /etc/sysconfig/network-scripts/ifdown-post $1
52 fi
53
54 exit 1
This page took 0.051144 seconds and 4 git commands to generate.