2009/02/12

Wait Up

If you find service startup (e.g. samba) failing because an interface started in the background isn't up in time, then waitup may be an answer:

#!/bin/bash

IFACE=$1
count=0
echo -n "Wait for ${IFACE}"

while ! /sbin/ifconfig ${IFACE} 2>/dev/null | grep -q "UP" ; do
echo -n "."
sleep 1
count=`expr $count + 1`
if [ $count -gt 10 ] ; then
echo "not found in 15sec - bailing"
exit 1
fi
done

echo ". ($count)"

exit 0