On 20020804 J.A. Magallon wrote:
> Hi all...
>
> I have two little problem with current cooker initscripts.
>
> - /etc/sysconfig/network-scripts/network-functions::check_link_down() has
> a fixed timeout of 2 secs to wait the link getting up. I had to increase
> this to 3 o 4 to make my sis900 (eth on laptop) initalize correctly. With
> the default sleep, the card was reported as 'link down, check cable'.
> I will try to mess with bash and post a patch to turn it into a loop with a
> number of tries (10) for 'ip link set up' with 1 sec sleep in each.
How 'bout this:
for (( try=0; try<10; try++))
do
if [ "$(ip link show $1 up)" ]; then
echo "Link is UP"
break
fi
echo "Link is DOWN, rising..."
ip link set $1 up &> /dev/null
sleep 1
done
It works but is bash specific.
Are initscripts supposed to run under plain sh ?? If not, there could
be much optimization and clearing, because bash let you do many things
not used in standard scripts (like the above '&> x', instead of '>x 2>&1' )
If you find it useful, I can turn it into a general function like
timed_retry attempts timeout what_to_do check_for_done
TIA
--
J.A. Magallon \ Software is like sex:
junk.able.es \ It's better when it's free
Mandrake Linux release 9.0 (Cooker) for i586
Linux 2.4.19-jam0 (gcc 3.2 (Mandrake Linux 9.0 3.2-0.2mdk))