aboutsummaryrefslogtreecommitdiffstats
path: root/network-scripts/ifdown-post
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-07-26 21:46:44 +0200
committerOlav Vitters <olav@vitters.nl>2020-07-26 21:46:44 +0200
commit244c9a00ae9a0dc62156aeb8781c2b22da0ad96e (patch)
treec0d76ed490862837a8a37bb61ed8e653e5cc2558 /network-scripts/ifdown-post
parentd0d18c6de12efeba25eb41d7cf207037027e4964 (diff)
parent6ca701a23c74b245f35750149a22f7d21805a8e0 (diff)
downloadinitscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.gz
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.bz2
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.xz
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.zip
Merge tag '10.04' into distro/mga
10.04 release
Diffstat (limited to 'network-scripts/ifdown-post')
-rwxr-xr-xnetwork-scripts/ifdown-post75
1 files changed, 75 insertions, 0 deletions
diff --git a/network-scripts/ifdown-post b/network-scripts/ifdown-post
new file mode 100755
index 00000000..4cf6aa61
--- /dev/null
+++ b/network-scripts/ifdown-post
@@ -0,0 +1,75 @@
+#!/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_true "${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 (empty ZONE means default):
+if [ "${REALDEVICE}" != "lo" ]; then
+ dbus-send --print-reply --system --dest=org.fedoraproject.FirewallD1 \
+ /org/fedoraproject/FirewallD1 \
+ org.fedoraproject.FirewallD1.zone.removeInterface \
+ string:"" string:"${DEVICE}" \
+ > /dev/null 2>&1
+fi
+
+mdv-network-event interface_down ${DEVICE}
+
+if [ -d /etc/sysconfig/network-scripts/ifdown.d -a -x /usr/bin/run-parts ]; then
+ /usr/bin/run-parts --arg ${DEVICE} /etc/sysconfig/network-scripts/ifdown.d
+fi
+
+if [ -x /sbin/ifdown-local ]; then
+ /sbin/ifdown-local ${DEVICE}
+fi
+
+exit 0