aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifdown-ppp
blob: e76732b9daf05a5424207d5ca1723ecc532dae6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin

cd /etc/sysconfig/network-scripts
. network-functions

CONFIG=$1
source_config

if [ "${DEMAND}" != no -a -f /var/run/ppp-${DEVICE}.pid ] ; then
    PID=`head -1 /var/run/ppp-${DEVICE}.pid`
    kill -TERM ${PID}
    sleep 2
    [ ! -d /proc/${PID} ] && exit 0
    sleep 5
    [ ! -d /proc/${PID} ] && exit 0
    kill -TERM ${PID}
    [ ! -d /proc/${PID} ] && exit 0
    exit 1
fi

file=/var/run/pppwatch-${DEVICE}.pid

if [ ! -f $file ]; then
    # ppp isn't running, or we didn't start it
    exit 0
fi

PID=`cat $file`
[ -n "${PID}" ] || exit 1

kill -TERM ${PID} > /dev/null 2>&1
[ ! -d /proc/${PID} ] && exit 0
sleep 2
[ ! -d /proc/${PID} ] && exit 0
sleep 5
[ ! -d /proc/${PID} ] && exit 0
sleep 10
[ ! -d /proc/${PID} ] && exit 0

# killing ppp-watch twice in a row causes it to send a SIGKILL to pppd pgrp
kill -TERM ${PID} > /dev/null 2>&1
[ ! -d /proc/${PID} ] && exit 0

exit 1