I was looking at different scripts out there and found the one below. I need an idea on how to randomize some of this because otherwise it will always be the same om all hosts and if there are 4 hba' as in my case the fourth one will newer be used. I need to set the counter to some random number between 1 and the PATHS value for the hba assignment to start somwhere.. :
#! /bin/bash
#
# by Allan Christiansen/2008 on esx 3.5.0 Update 1#for PATHS in 2 4 6 8 10 12 14 16doSTPATHS=${PATHS}COUNTER=${RANDOM}while [[ ${COUNTER} -gt ${PATHS} ]];doCOUNT=`expr ${COUNTER} / ${PATHS}`COUNTER=${COUNT}donefor LUN in $(esxcfg-mpath -l | grep "Disk" | grep "has ${STPATHS} paths" | awk '{print $2}')doesxcfg-mpath --lun=${LUN} --path=$(esxcfg-mpath -q --lun=${LUN} | grep FC | awk '{print $4}' | awk '{print NR "S\t " $0}' | grep ${COUNTER}S | awk '{print $2}') --preferredCOUNT=`expr ${COUNTER} + 1`COUNTER=${COUNT}if [[ ${COUNTER} -gt ${STPATHS} ]]thenCOUNTER="1"fidonedone