aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifdown-post
blob: 04d516d50b13ed41cd9745b56ec6744f62373865 (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
46
#!/bin/sh
# This should be called whenever an interface goes down, not just when
# it is brought down explicitly.

PATH=/sbin:/usr/sbin:/bin:/usr/bin

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

CONFIG=$1
source_config

DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`

if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then
    if [ -f /etc/resolv.conf.save ]; then
	cat /etc/resolv.conf.save > /etc/resolv.conf
	rm -f /etc/resolv.conf.save
    fi
    if [ -f /etc/ppp/peers/$DEVICE ] ; then
	rm -f /etc/ppp/peers/$DEVICE
    fi
fi

# Reset the default route if this interface had a special one
if ! check_default_route ; then
    # ISDN device needs special handling dial on demand
    if [ "${DEVICETYPE}" = "ippp" -o "${DEVICETYPE}" = "isdn" ] && [ "$DIALMODE" = "auto" ] ; then
        if [ -z "$GATEWAY" ] ; then
            /sbin/ip route add default dev ${DEVICE}
        else
            /sbin/ip route add default via ${GATEWAY}
        fi
    else
        add_default_route ${DEVICE}
    fi
fi

# Notify programs that have requested notification
do_netreport

if [ -x /sbin/ifdown-local ]; then
    /sbin/ifdown-local ${DEVICE}
fi

exit 0