ifcfg-rh: allow handling complex routing rules via dispatcher (rh #1160013)
[NetworkManager.git] / examples / dispatcher / 10-ifcfg-rh-routes.sh
1 #!/bin/sh
2
3 # This ifcfg-rh-specific script runs
4 # /etc/sysconfig/network-scripts/ifup-routes when bringing up
5 # interfaces that have routing rules associated with them that can't
6 # be expressed by NMSettingIPConfig. (Eg, policy-based routing.)
7
8 # This should be installed in dispatcher.d/pre-up.d/
9
10 dir=$(dirname "$CONNECTION_FILENAME")
11 if [ "$dir" != "/etc/sysconfig/network-scripts" ]; then
12     exit 0
13 fi
14 profile=$(basename "$CONNECTION_FILENAME" | sed -ne 's/^ifcfg-//p')
15 if [ -z "$profile" ]; then
16     exit 0
17 fi
18
19 if [ -f "$dir/rule-$profile" -o -f "$dir/rule6-$profile" ]; then
20     /etc/sysconfig/network-scripts/ifup-routes "$DEVICE_IP_IFACE" "$profile"
21 fi