summaryrefslogtreecommitdiff
path: root/examples/dispatcher/10-ifcfg-rh-routes.sh
blob: 75b8c5e5e9d8dd1b7eb1ccd2c3a9d07c1be088d0 (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
#!/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