Hi funguy
I think this should work:
#!/bin/sh
NicCount=0
Timeout=10
for NICS in `ls -1 /sys/class/net`
do
[ "$NICS" = "dummy0" ] && continue
[ "$NICS" = "lo" ] && continue
let "NicCount += 1"
/bin/rm -f /tmp/$NICS.found
done
while [ $Timeout -gt 0 ]
do
for NICS in `ls -1 /sys/class/net`
do
[ "$NICS" = "dummy0" ] && continue
[ "$NICS" = "lo" ] && continue
if [ ! -e /tmp/$NICS.found ]
then
if [ `/bin/grep 1 /sys/class/net/$NICS/carrier` ]
then
touch /tmp/$NICS.found
let "NicCount -= 1"
fi
fi
done
[ $NicCount -le 0 ] && break
sleep 1
let "Timeout -= 1"
done
echo $NicCount
The script will continue to execute until all the network interfaces are brought up. Should any interfaces fail
to come up, there is a 10 second timeout to terminate the loop. If all the interfaces were brought up, it
returns 0, otherwise it returns the number of interfaces that failed to come up.