--- iproute2-2.6.18-061002/ip/ifcfg.orig 2006-10-02 23:13:34 +0300 +++ iproute2-2.6.18-061002/ip/ifcfg 2006-10-12 15:50:40 +0300 @@ -1,4 +1,6 @@ -#! /bin/bash +#! /bin/sh + +export PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin" CheckForwarding () { local sbase fwd @@ -22,17 +24,17 @@ local class; class=${1%%.*} - if [ "$1" = "" -o $class -eq 0 -o $class -ge 224 ]; then return 0 - elif [ $class -ge 224 ]; then return 0 - elif [ $class -ge 192 ]; then return 24 - elif [ $class -ge 128 ]; then return 16 + if [ -z "$1" ] || [ "$class" -eq 0 -o "$class" -ge 224 ]; then return 0 + elif [ "$class" -ge 224 ]; then return 0 + elif [ "$class" -ge 192 ]; then return 24 + elif [ "$class" -ge 128 ]; then return 16 else return 8; fi } label="label $1" ldev="$1" dev=${1%:*} -if [ "$dev" = "" -o "$1" = "help" ]; then +if [ -z "$dev" -o "$1" = "help" ]; then echo "Usage: ifcfg DEV [[add|del [ADDR[/LEN]] [PEER] | stop]" 1>&2 echo " add - add new address" 1>&2 echo " del - delete address" 1>&2 @@ -66,12 +68,12 @@ ipaddr= pfxlen= -if [ "$1" != "" ]; then +if [ -n "$1" ]; then ipaddr=${1%/*} if [ "$1" != "$ipaddr" ]; then pfxlen=${1#*/} fi - if [ "$ipaddr" = "" ]; then + if [ -z "$ipaddr" ]; then echo "$1 is bad IP address." 1>&2 exit 1 fi @@ -79,8 +81,8 @@ shift peer=$1 -if [ "$peer" != "" ]; then - if [ "$pfxlen" != "" -a "$pfxlen" != "32" ]; then +if [ -n "$peer" ]; then + if [ -n "$pfxlen" -a "$pfxlen" != "32" ]; then echo "Peer address with non-trivial netmask." 1>&2 exit 1 fi @@ -90,14 +92,14 @@ echo "Missing IP address argument." 1>&2 exit 1 fi - if [ "$pfxlen" = "" ]; then + if [ -z "$pfxlen" ]; then ABCMaskLen $ipaddr pfxlen=$? fi pfx="$ipaddr/$pfxlen" fi -if [ "$ldev" = "$dev" -a "$ipaddr" != "" ]; then +if [ "$ldev" = "$dev" -a -n "$ipaddr" ]; then label= fi @@ -112,7 +114,7 @@ echo "Error: cannot enable interface $dev." 1>&2 exit 1 fi -if [ "$ipaddr" = "" ]; then exit 0; fi +if [ -z "$ipaddr" ]; then exit 0; fi if ! arping -q -c 2 -w 3 -D -I $dev $ipaddr ; then echo "Error: some host already uses address $ipaddr on $dev." 1>&2 @@ -131,14 +133,14 @@ ip route add unreachable 224.0.0.0/24 >& /dev/null ip route add unreachable 255.255.255.255 >& /dev/null -if [ `ip link ls $dev | grep -c MULTICAST` -ge 1 ]; then +if [ "`ip link ls $dev | grep -c MULTICAST`" -ge 1 ]; then ip route add 224.0.0.0/4 dev $dev scope global >& /dev/null fi if [ $fwd -eq 0 ]; then if [ $noarp -eq 0 ]; then ip ro append default dev $dev metric 30000 scope global - elif [ "$peer" != "" ]; then + elif [ -n "$peer" ]; then if ping -q -c 2 -w 4 $peer ; then ip ro append default via $peer dev $dev metric 30001 fi