From: Serge L. <sma...@us...> - 2010-09-08 08:47:23
|
Update of /cvsroot/devil-linux/build/config/etc/init.d In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv30891 Modified Files: network Log Message: - added possibility for CIDR notation (IP address and NETMASK) Index: network =================================================================== RCS file: /cvsroot/devil-linux/build/config/etc/init.d/network,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- network 1 Sep 2010 20:14:27 -0000 1.50 +++ network 8 Sep 2010 08:47:15 -0000 1.51 @@ -215,8 +215,13 @@ dhcp_client_start $DEVICE "$DHCP_OPTIONS" else + tmp=$(echo $IP | awk -F'/' '{print $1,$2}') # for CIDR notation IP=123.123.123.123/23 + set -- $tmp + IP=$1; NMASK=$2; + if [ -z "$NMASK" ]; then + test -n "$NETMASK" && NMASK=$(echo $NETMASK | sed 's#/##') # for CIDR notation NETMASK=/22 + fi BCAST=""; test -n "$BROADCAST" && BCAST="broadcast $BROADCAST" || BCAST="broadcast +" - NMASK=""; test -n "$NETMASK" && NMASK="/$NETMASK" # Not elegant, but for code below $DEVICE sould be a tunnel name if [ "$TUNNEL" = "yes" ]; then @@ -228,7 +233,7 @@ echo -n "Starting interface $DEVICE "; ret=0 if [ "$TUNNEL" = "yes" ]; then - ip tunnel add $DEVICE mode $MODE local $LOCAL remote $REMOTE $TUN_DEVICE $TUN_OPTS; let ret=$ret+$? + ip tunnel add $DEVICE mode $MODE local $LOCAL remote $REMOTE $TUN_DEVICE $TUN_OPTS; let ret=$ret+$? fi ip link set $DEVICE up; let ret=$ret+$? @@ -239,9 +244,9 @@ if echo $DEVICE | grep ':' > /dev/null ; then LABEL=$DEVICE DEVICE=$(echo $LABEL | cut -d':' -f1) - ip addr add $IP$NMASK $BCAST dev $DEVICE label $LABEL; let ret=$ret+$? + ip addr add $IP/$NMASK $BCAST dev $DEVICE label $LABEL; let ret=$ret+$? else - ip addr add $IP$NMASK $BCAST dev $DEVICE ; let ret=$ret+$? + ip addr add $IP/$NMASK $BCAST dev $DEVICE ; let ret=$ret+$? fi fi @@ -364,8 +369,13 @@ [ "$DHCP" == yes ] && dhcp_client_stop echo "Removing ip address from interface $DEVICE" - BCAST=""; test -n "$BROADCAST" && BCAST="broadcast $BROADCAST" - NMASK=""; test -n "$NETMASK" && NMASK="/$NETMASK" + tmp=$(echo $IP | awk -F'/' '{print $1,$2}') # for CIDR notation IP=123.123.123.123/23 + set -- $tmp + IP=$1; NMASK=$2; + if [ -z "$NMASK" ]; then + test -n "$NETMASK" && NMASK=$(echo $NETMASK | sed 's#/##') # for CIDR notation NETMASK=/22 + fi + BCAST=""; test -n "$BROADCAST" && BCAST="broadcast $BROADCAST" || BCAST="broadcast +" if [ -n "$IP" ]; then # configure IPv4 address @@ -373,9 +383,9 @@ if echo $DEVICE | grep ':' > /dev/null ; then LABEL=$DEVICE DEVICE=$(echo $LABEL | cut -d':' -f1) - ip addr del $IP$NMASK $BCAST dev $DEVICE label $LABEL + ip addr del $IP/$NMASK $BCAST dev $DEVICE label $LABEL else - ip addr del $IP$NMASK $BCAST dev $DEVICE + ip addr del $IP/$NMASK $BCAST dev $DEVICE fi fi |