Files
NetworkManager/examples/dispatcher/10-ifcfg-rh-routes.sh
Dan Winship 8de1bec803 dispatcher: fix ifcfg-rh example dispatcher script (rh #1160013)
Routing table entries for a device get flushed when the device is
deactivated, but rules table entries don't, so we have to flush them
by hand.
2015-01-27 13:51:45 -05:00

35 lines
912 B
Bash
Executable File

#!/bin/sh
# This ifcfg-rh-specific script runs
# /etc/sysconfig/network-scripts/ifup-routes when bringing up
# interfaces that have routing rules associated with them that can't
# be expressed by NMSettingIPConfig. (Eg, policy-based routing.)
# This should be installed in both dispatcher.d/ and
# dispatcher.d/pre-up.d/
if [ "$2" != "pre-up" -a "$2" != "down" ]; then
exit 0
fi
dir=$(dirname "$CONNECTION_FILENAME")
if [ "$dir" != "/etc/sysconfig/network-scripts" ]; then
exit 0
fi
profile=$(basename "$CONNECTION_FILENAME" | sed -ne 's/^ifcfg-//p')
if [ -z "$profile" ]; then
exit 0
fi
if ! [ -f "$dir/rule-$profile" -o -f "$dir/rule6-$profile" ]; then
exit 0
fi
case "$2" in
pre-up)
/etc/sysconfig/network-scripts/ifup-routes "$DEVICE_IP_IFACE" "$profile"
;;
down)
/etc/sysconfig/network-scripts/ifdown-routes "$DEVICE_IP_IFACE" "$profile"
;;
esac