#!/bin/sh
#
# $Header: allBladesOp 1.2 2006/09/22 10:58:07MDT Ahmed Teirelbar (ateirelbar) dev  $
#
# $ADICCopyright: Copyright 2007 Quantum Corp. $
#
# $Log: allBladesOp  $
# Revision 1.2 2006/09/22 10:58:07MDT Ahmed Teirelbar (ateirelbar) 
# Getting third octet from ifconfig instead of hardcoded
# l
# Revision 1.1 2006/09/08 22:31:59GMT ateirelbar 
# Initial revision
# Member added to project e:/mks/projects/ccDevModel/Code/Applications/Scalar101/S101SystemBuild/project.pj
#
EXPECT=/usr/bin/expect
FPING=/usr/sbin/fping
SINGLEDAB=/home/embedded/library/singleBladeOp

applicationHome="/home/embedded/library"
applicationIncludeName="${applicationHome}/AppManager/bin/include.sh"

. ${applicationIncludeName}

allBladesOp() {
    CMD_OP=$1;

    DAB_OCTET=`ifconfig eth1 | grep inet | awk -F "." '{print $3}'`
    DAB_NETWORK="10.10.$DAB_OCTET.0/24"
    printf "Testing install..."
    if [ ! -e ${FPING} ]; then
    printf "Please install the fping binary!\n"
    return 1
    fi
    
    if [ ! -e ${EXPECT} ]; then
	     printf "Please install the Tcl/Expect package!\n"
	     return 1
    fi
    printf "OK.\n"
    
    printf "Broadcasting for DABs..."
    fping -a -r1 -g ${DAB_NETWORK} > installed 2>/dev/null
    printf "OK.\n"
    
    while read DAB; do
    if [ ${DAB} != "10.10.11.1" ]; then 
        LogInfo "Capturing info for blade: ${DAB}"
	     CMD_STR="expect ${SINGLEDAB} ${DAB} '${CMD_OP}'"
	     eval $CMD_STR;
        LogInfo "Result code from blade capture: $?"
    fi
    done < installed

    return 0;
}