aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-routes
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig/network-scripts/ifup-routes')
-rwxr-xr-xsysconfig/network-scripts/ifup-routes39
1 files changed, 23 insertions, 16 deletions
diff --git a/sysconfig/network-scripts/ifup-routes b/sysconfig/network-scripts/ifup-routes
index db3e51ea..ff8d5b56 100755
--- a/sysconfig/network-scripts/ifup-routes
+++ b/sysconfig/network-scripts/ifup-routes
@@ -6,6 +6,8 @@ if [ -z "$1" ]; then
exit 1
fi
+MATCH='^[[:space:]]*(\#.*)?$'
+
handle_file () {
. $1
routenum=0
@@ -21,13 +23,26 @@ handle_file () {
done
}
-FILES="/etc/sysconfig/network-scripts/route-$1"
+handle_ip_file() {
+ local f t type= file=$1 proto="-4"
+ f=${file##*/}
+ t=${f%%-*}
+ type=${t%%6}
+ if [ "$type" != "$t" ]; then
+ proto="-6"
+ fi
+ { cat "$file" ; echo ; } | while read line; do
+ if [[ ! "$line" =~ $MATCH ]]; then
+ /sbin/ip $proto $type add $line
+ fi
+ done
+}
+
+FILES="/etc/sysconfig/network-scripts/route-$1 /etc/sysconfig/network-scripts/route6-$1"
if [ -n "$2" -a "$2" != "$1" ]; then
- FILES="$FILES /etc/sysconfig/network-scripts/route-$2"
+ FILES="$FILES /etc/sysconfig/network-scripts/route-$2 /etc/sysconfig/network-scripts/route6-$2"
fi
-MATCH='^[[:space:]]*(\#.*)?$'
-
for file in $FILES; do
if [ -f "$file" ]; then
if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $file ; then
@@ -35,11 +50,7 @@ for file in $FILES; do
handle_file $file ${1%:*}
else
# older format
- { cat "$file" ; echo ; } | while read line; do
- if [[ ! "$line" =~ $MATCH ]]; then
- /sbin/ip route add $line
- fi
- done
+ handle_ip_file $file
fi
fi
done
@@ -52,17 +63,13 @@ CONFIG="/etc/sysconfig/network-scripts/$NICK.route"
# Routing rules
-FILES="/etc/sysconfig/network-scripts/rule-$1"
+FILES="/etc/sysconfig/network-scripts/rule-$1 /etc/sysconfig/network-scripts/rule6-$1"
if [ -n "$2" -a "$2" != "$1" ]; then
- FILES="$FILES /etc/sysconfig/network-scripts/rule-$2"
+ FILES="$FILES /etc/sysconfig/network-scripts/rule-$2 /etc/sysconfig/network-scripts/rule6-$2"
fi
for file in $FILES; do
if [ -f "$file" ]; then
- { cat "$file" ; echo ; } | while read line; do
- if [[ ! "$line" =~ $MATCH ]]; then
- /sbin/ip rule add $line
- fi
- done
+ handle_ip_file $file
fi
done