diff options
author | Bill Nottingham <notting@redhat.com> | 2003-07-01 15:02:49 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2003-07-01 15:02:49 +0000 |
commit | b9a641566adbdb7f5ade6939984c330bcdcb4722 (patch) | |
tree | 7a09eb26345af703230e1ffb19152574b80982e8 /sysconfig/network-scripts/ifup-routes | |
parent | 6c9647693c0ed24eb1d034928aaa0135fe4dda56 (diff) | |
download | initscripts-b9a641566adbdb7f5ade6939984c330bcdcb4722.tar initscripts-b9a641566adbdb7f5ade6939984c330bcdcb4722.tar.gz initscripts-b9a641566adbdb7f5ade6939984c330bcdcb4722.tar.bz2 initscripts-b9a641566adbdb7f5ade6939984c330bcdcb4722.tar.xz initscripts-b9a641566adbdb7f5ade6939984c330bcdcb4722.zip |
handle new format in old file names
Diffstat (limited to 'sysconfig/network-scripts/ifup-routes')
-rwxr-xr-x | sysconfig/network-scripts/ifup-routes | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/sysconfig/network-scripts/ifup-routes b/sysconfig/network-scripts/ifup-routes index 5a11f4a7..37bd2287 100755 --- a/sysconfig/network-scripts/ifup-routes +++ b/sysconfig/network-scripts/ifup-routes @@ -6,26 +6,8 @@ if [ -z "$1" ]; then exit 1 fi -# Older format -if [ -f "/etc/sysconfig/network-scripts/route-$1" ]; then - while read line; do - /sbin/ip route add $line - done < "/etc/sysconfig/network-scripts/route-$1" -fi - -if [ -n "$2" -a "$2" != "$1" ]; then - if [ -f "/etc/sysconfig/network-scripts/route-$2" ]; then - while read line; do - /sbin/ip route add $line - done < "/etc/sysconfig/network-scripts/route-$2" - fi -fi - -# Red Hat network configuration format -NICK=${2:-$1} -CONFIG="/etc/sysconfig/network-scripts/$NICK.route" -if [ -f $CONFIG ]; then - . $CONFIG +handle_file () { + . $1 routenum=0 while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do eval `ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum)` @@ -37,4 +19,29 @@ if [ -f $CONFIG ]; then /sbin/ip route add $line routenum=$(($routenum+1)) done +} + +FILES="/etc/sysconfig/network-scripts/route-$1" +if [ -n "$2" -a "$2" != "$1" ]; then + FILES="$FILES /etc/sysconfig/network-scripts/route-$2" fi + +for file in $FILES; do + if [ -f "$file" ]; then + if egrep -q 'ADDRESS[0-9]+=' $file ; then + # new format + handle_file $file + else + # older format + while read line; do + /sbin/ip route add $line + done < "$FILE" + fi + fi +done + + +# Red Hat network configuration format +NICK=${2:-$1} +CONFIG="/etc/sysconfig/network-scripts/$NICK.route" +[ -f $CONFIG ] && handle_file $CONFIG |