Re: [Cooker] initscripts and eth

2002-08-08 Thread Warly

"J.A. Magallon" <[EMAIL PROTECTED]> writes:

> New try (of course echo's should be killed for real initscripts):
>
> check_link_down ()
> {
> if [ ! -x /sbin/mii-tool ]; then
> return 0
> fi
>
> if [ -z "$(ip link show $1 up)" ]; then
> echo "Link" $1 "is DOWN, rising..."
> ip link set $1 up
> fi
>
> for (( try=0; try<10; try++ ))
> do
> output=`LC_ALL=C mii-tool $LINK $1 2>&1`
> if echo $output | grep -vqs "no link"; then
> echo "Link" $1 "is UP"
> return 1
> fi
> sleep 1
> done
> echo "Failed to raise" $1 "after 10 seconds"
> return 0
> }
>
> $LINK can be assigned in ifcfg-eth0, for example I have LINK="-F 10baseT-FD".
>
> Do not know if this matters for somebody, but the fact is that with default
> latest initscripts I thought my cablemodem was broken until I (sigh) booted
> windows on the laptop.

I have integrated this in the initscripts-6.87-2mdk, could you test ?

-- 
Warly




Re: [Cooker] initscripts and eth

2002-08-04 Thread Buchan Milne



[EMAIL PROTECTED], [EMAIL PROTECTED] wrote:
>
>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 they are, then they are all broken. Try installing ash and linking it as /bin/sh
instead of bash. Then, try and reboot. Good luck, you will have to reboot again with
init=/bin/bash and relink bash as /bin/sh!

IMHO, the scripts should either be fixed to work with any standard sh, or have their
hashbang changed from #!/bin/sh to #!/bin/bash

>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' )

IMHO, use bash-isms, as long as the script calls bash, and not sh.

Buchan





Re: [Cooker] initscripts and eth

2002-08-04 Thread J.A. Magallon


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))




[Cooker] initscripts and eth

2002-08-03 Thread J.A. Magallon

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.
- This damned sis900 is capable to talk to the cablemodem at FullDX, but
  the autonegotiation does not work. I forced a /sbin/mii-tool -F 10baseT-FD
  in the same function as above. This can be a 'popular' scenario. Could
  you add a new variable, such as MIIFLAGS, in ifconfig-eth0, so as to do
  
  /sbin/mii-tool $MIIFLAGS >/dev/null 2>&1 || return 1

  to override defaults, or force non autodetected options ?

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))