aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifdown-post
blob: afafc0d56c3b43c559203e6b430c9f63e80c8ea8 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# This should be called whenever an interface goes down, not just when
# it is brought down explicitly.

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

unset REALDEVICE
if [ "$1" = --realdevice ] ; then
    REALDEVICE=$2
    shift 2
fi

CONFIG=$1
source_config

[ -z "$REALDEVICE" ] && REALDEVICE=$DEVICE

/etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE} ${DEVNAME}

# Remove duplicate DNS entries and shift them,
# to have always correct condition below...
update_DNS_entries

if ! is_false "${PEERDNS}" || ! is_false "${RESOLV_MODS}" && \
    [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" -o -n "${DNS1}" \
    -o "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ] ; then
    if [ -f /etc/resolv.conf.save ]; then
        change_resolv_conf /etc/resolv.conf.save
        rm -f /etc/resolv.conf.save
    fi
    if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then
        if [ -f /etc/ppp/peers/$DEVICE ] ; then
            rm -f /etc/ppp/peers/$DEVICE
        fi
    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 ${METRIC:+metric} \
                ${WINDOW:+window $WINDOW} dev ${DEVICE}
        else
            /sbin/ip route add default ${METRIC:+metric} \
                ${WINDOW:+window $WINDOW} via ${GATEWAY}
        fi
    else
        add_default_route ${DEVICE}
    fi
fi

# Reset firewall ZONE to "default":
if [ "${REALDEVICE}" != "lo" ]; then
    dbus-send --system --dest=org.fedoraproject.FirewallD1 \
              /org/fedoraproject/FirewallD1 \
              org.fedoraproject.FirewallD1.zone.removeInterface \
              string: "" string:"${DEVICE}" \
              > /dev/null 2>&1
fi

# Notify programs that have requested notification
do_netreport

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

exit 0