Diff for /elwix/config/etc/default/rc.d/009.aggr_dev.stop between versions 1.1 and 1.2

version 1.1, 2013/01/23 12:49:12 version 1.2, 2013/01/28 01:47:36
Line 0 Line 1
   #!/bin/sh
   #
   # (C)`13 ELWIX network aggregation device appliance
   #       by Michael Pounov <misho@elwix.org>
   #
   # $Id$
   
   IFACES=""
   LANPORT=""
   BRIDGE=""
   LAGG=""
   LAGGPORTS=""
   
   CLEANUP_FILE="/tmp/cleanup.agg"
   
   select_eth()
   {
           local RETIF=""
   
           IFACES=$(ifconfig -l)
   
           for i in $IFACES; do
                   ISETH=$(ifconfig $i | grep "ether")
                   if [ -n "$ISETH" ]; then
                           RETIF="$RETIF $i"
                   fi
           done
   
           IFACES=$RETIF
   }
   
   cleanup()
   {
           echo ">> Emergency destroy clones ..."
           ifconfig $BRIDGE destroy >/dev/null 2>&1
           ifconfig $LAGG destroy >/dev/null 2>&1
           rm -f $CLEANUP_FILE
   }
   
   up_lan()
   {
           echo "+ Up lan port $1"
           if ! `ifconfig $1 description "LAN port" up`; then
                   exit 1
           else
                   LANPORT=$1
           fi
   }
   
   up_others()
   {
           if [ $# -lt 2 ]; then
                   echo "Error:: Not enough ethernet interfaces for aggregation!"
                   exit 2
           else
                   shift
                   LAGGPORTS=$*
           fi
   
           for i in $LAGGPORTS; do
                   echo "+ Up aggregation port $i"
                   if ! `ifconfig $i description "Aggregation port" up`; then
                           exit 2
                   fi
           done
   }
   
   bring_clones()
   {
           rm -f $CLEANUP_FILE
   
           BRIDGE=$(ifconfig bridge create up)
           if [ -z "$BRIDGE" ]; then
                   exit 3
           else
                   echo "+ Create link-bridge interface $BRIDGE"
                   echo $BRIDGE >>/tmp/cleanup.agg
           fi
   
           LAGG=$(ifconfig lagg create laggproto roundrobin up)
           if [ -z "$LAGG" ]; then
                   ifconfig $BRIDGE destroy >/dev/null 2>&1
                   rm -f $CLEANUP_FILE
                   exit 3
           else
                   echo "+ Create link-aggregation interface $LAGG"
                   echo $LAGG >>/tmp/cleanup.agg
           fi
   }
   
   join2lagg()
   {
           echo "+ Join to aggregation interface $LAGG ports $LAGGPORTS"
   
           for i in $LAGGPORTS; do
                   if ! `ifconfig $LAGG laggport $i`; then
                           cleanup
                           exit 4
                   fi
           done
   }
   
   join2bridge()
   {
           echo "+ Join to bridge interface $BRIDGE ports $LANPORT $LAGG"
   
           if ! `ifconfig $BRIDGE addm $LANPORT addm $LAGG`; then
                   cleanup
                   exit 5
           fi
   }
   
   # main()
   if [ -n "$1" ]; then
           echo ">> Cleanup cloned interfaces ..."
   
           if [ -r $CLEANUP_FILE ]; then
                   while read line; do
                           if ! `ifconfig $line >/dev/null 2>&1`; then
                                   break
                           else
                                   ifconfig $line destroy >/dev/null 2>&1
                           fi
                   done <$CLEANUP_FILE
   
                   rm -f $CLEANUP_FILE
           fi
   else
           echo ">> Setup aggregation device ..."
           select_eth
   
           up_lan $IFACES
           up_others $IFACES
   
           bring_clones
           join2lagg
           join2bridge
   fi
   
   echo ">> Done."

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>