-# Set the IP alias needed by a vserver
-ifconfig_iproot()
-{
- if [ "$NODEV" = "" -a "$IPROOT" != "" -a "$IPROOT" != "0.0.0.0" -a "$IPROOT" != "ALL" ] ;then
- # A vserver may have more than one IP
- # The first alias is dev:vserver
- # and the other are dev:vserver1,2,3 and so on
- # An IP may hold the device. The following is valid
- # IPROOT="1.2.4.5 eth1:1.2.3.5"
- # IPROOTDEV=eth0
- # The first IP 1.2.3.4 will go on eth0 and the other on eth1
- # VLAN devices are also supported (eth0.231 for vlan 231)
- SUFFIX=
- for oneip in $IPROOT
- do
- IPDEV=$IPROOTDEV
- MASK=$IPROOTMASK
- BCAST=$IPROOTBCAST
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo oneip=$ip; echo IPDEV=$dev)`
- ;;
- esac
- # Split the IP and the netmask if available
- case $oneip in
- */*)
- eval `echo $oneip | tr / ' ' | (read ip msk; echo oneip=$ip; echo MASK=$msk)`
- eval `$USR_LIB_VSERVER/ifspec "" "$oneip" "$MASK" "$BCAST"`
- ;;
- esac
- if [ "$IPDEV" != "" ] ; then
- case $IPDEV in
- *.*)
- if [ ! -f /proc/net/vlan/$IPDEV ] ; then
- /sbin/vconfig add `echo $IPDEV | tr . ' '`
- # Put a dummy IP
- /sbin/ifconfig $IPDEV 127.0.0.1
- fi
- ;;
- esac
- # Compute the default netmask, if missing
- eval `$USR_LIB_VSERVER/ifspec $IPDEV "$oneip" "$MASK" "$BCAST"`
- IPROOTMASK=$NETMASK
- IPROOTBCAST=$BCAST
- #echo /sbin/ifconfig $IPDEV:$1$SUFFIX $oneip netmask $IPROOTMASK broadcast $IPROOTBCAST
- /sbin/ifconfig $IPDEV:$1$SUFFIX $oneip netmask $IPROOTMASK broadcast $IPROOTBCAST
- fi
- if [ "$SUFFIX" = "" ] ; then
- SUFFIX=1
- else
- SUFFIX=`expr $SUFFIX + 1`
- fi
- done
- fi
- if [ "$IPROOTBCAST" = "" ] ; then
- IPROOTBCAST=255.255.255.255
- fi
-}
-ifconfig_iproot_off()
-{
- if [ "$NODEV" = "" -a "$IPROOT" != "" -a "$IPROOT" != "0.0.0.0" -a "$IPROOT" != "ALL" -a "$IPROOTDEV" != "" ] ;then
- SUFFIX=
- for oneip in $IPROOT
- do
- IPDEV=$IPROOTDEV
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo IPDEV=$dev)`
- ;;
- esac
- /sbin/ifconfig $IPDEV:$1$SUFFIX down 2>/dev/null
- if [ "$SUFFIX" = "" ] ; then
- SUFFIX=1
- else
- SUFFIX=`expr $SUFFIX + 1`
- fi
- done
- fi
-}
-# Split an IPROOT definition, trash the devices and
-# compose a set of --ip option for chbind
-setipopt(){
- RET=
- IPS="$*"
- if [ "$IPS" = "" ] ; then
- IPS=0.0.0.0
- fi
- if [ "$1" = "ALL" ] ; then
- IPS=`$USR_LIB_VSERVER/listdevip`
- fi
- for oneip in $IPS
- do
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo oneip=$ip)`
- ;;
- esac
- #case $oneip in
- #*/*)
- # eval `echo $oneip | tr / ' ' | (read ip msk; echo oneip=$ip)`
- # ;;
- #esac
- echo --ip $oneip
- done
-}