Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
speeding up /etc/init.d/net.eth* when no link present
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
costa1977
n00b
n00b


Joined: 16 Sep 2003
Posts: 25
Location: PA, US

PostPosted: Fri Jun 17, 2005 5:56 pm    Post subject: speeding up /etc/init.d/net.eth* when no link present Reply with quote

I'm a laptop user. Each time when I boot up my laptop, if I don't have my network cable plugged in, the DHCP process will take forever when starting /etc/init.d/net.eth0. So, I have a tiny patch to /etc/init.d/net.eth0 (which is a symbol link to net.lo), to check whether the cable is indeed plugged in. The patch is against sys-apps/baselayout-1.11.12-r4, and it depends on net-tools because mii-tool is used.


Code:
# diff -uN /etc/init.d/net.lo.old /etc/init.d/net.lo
--- /etc/init.d/net.lo.old     2005-06-17 13:54:11.000000000 -0400
+++ /etc/init.d/net.lo  2005-06-17 13:51:22.000000000 -0400
@@ -695,6 +695,14 @@
                fi
        fi
 
+       #check if the link is actually connected. only work with ethernet, require mii-tool
+       nolink=$(/sbin/mii-tool ${IFACE} 2>${devnull}|grep "no link")
+       if [[ ${nolink}z != z ]]; then
+               #we got no link
+               ebegin "Checking link availability on ${nolink}"
+               eend 1
+               return 1
+       fi
        # Don't let preup modify us
        iface=${1}
        local IFACE=${iface} IFVAR=${ifvar} config
Back to top
View user's profile Send private message
Sm1
Apprentice
Apprentice


Joined: 02 Dec 2003
Posts: 251
Location: Ames, IA

PostPosted: Fri Jun 17, 2005 6:02 pm    Post subject: Reply with quote

You might want to look into ifplugd.

I'm not sure if all ethernet controllers support it, but on my thinkpad I just have ifplugd start when I boot. If a link is detected, it launches net.eth0, as soon as the link dissappears then it stops net.eth0.

Its very handy to have, especially if I am about to go wireless from being wired, pull the cable, and enable my wireless and I'm set.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum