View previous topic :: View next topic |
Author |
Message |
thatguy n00b
Joined: 18 Feb 2003 Posts: 13
|
Posted: Wed Aug 06, 2003 2:14 am Post subject: skip eth0,etc. during boot if away from lan/wireless |
|
|
I had the frequent annoyance of what seemed like an eternal boot when starting up my laptop in an office with no network or wireless. dhcpd would take what seemed forever to time out on each device. Here's a fragment to add to your /etc/init.d/net.ethx that will prompt you to skip or forge ahead with starting up your nic. default is to skip.
Code: |
bypass() {
ebegin "Press s to skip eth init"
if read -n1 -t 2 choice
then
[[ "$choice" == "s" ]] && return 1 || return 0
else return 1
fi
}
start() {
checkconfig || return 1
bypass || return 1
|
|
|
Back to top |
|
|
Garbz Apprentice
Joined: 02 Jul 2003 Posts: 260 Location: Brisbane, Australia
|
Posted: Wed Aug 06, 2003 3:13 pm Post subject: |
|
|
This is nice. This is much better than my original thought on this topic.
I wrote a script to change the runlevel based on my grub menu selection and skip net.eth0 / customize the bootup, but if i had known about this it would have been awesom.
Would also have cut the programming time from 15 min to about 5
I may impliment this on my sister's laptop so she doesn't screw things up when picking runlevels ! Thanks. _________________ Every begining is another begining's end. |
|
Back to top |
|
|
carambola5 Apprentice
Joined: 10 Jul 2002 Posts: 214
|
Posted: Wed Aug 06, 2003 7:43 pm Post subject: |
|
|
nicely done.
consider your code officially added to my laptop. works beautifully. I advise anyone with a laptop to implement this tip. I have always had to log in as root (or, I suppose issue a sudo command) in order to start up my wired/wireless cards.
It's simple tips like this that make life a bit easier for the average linux user. |
|
Back to top |
|
|
zojas Veteran
Joined: 22 Apr 2002 Posts: 1138 Location: Phoenix, AZ
|
Posted: Thu Aug 07, 2003 6:06 am Post subject: |
|
|
my laptop has two different ethernets (eth0 & eth1, eth0 is wired ethernet, eth1 is wireless). My solution was to create multiple virtual runlevels. 'default' starts up no ethernet, 'work' starts up eth0, 'home' starts up eth1. then at boot I have no network, once I log in I switch to the appropriate runlevel.
then I have different generic runlevels for wired ethernet with dhcp & wireless with dhcp. since the different runlevels need different settings in /etc/conf.d/net, I wrote some simple scripts which put different settings in conf.d/net then change the runlevel.
I have full details at the link in my sig. It's all slightly more complicated then just optionally skipping eth0 at boot, but it's MUCH more flexible. _________________ http://www.desertsol.com/~kevin/ppc |
|
Back to top |
|
|
Garbz Apprentice
Joined: 02 Jul 2003 Posts: 260 Location: Brisbane, Australia
|
Posted: Thu Aug 07, 2003 7:17 am Post subject: |
|
|
It seems that everyone with a laptop found their own solution to the problem.
Is there anyway to background the process as well? I.e. let it start normally but don't halt the boot process for it ?
I am aware this would cause message to appear out of order. _________________ Every begining is another begining's end. |
|
Back to top |
|
|
boobytrapped n00b
Joined: 09 Dec 2002 Posts: 31 Location: Toronto, Canada
|
Posted: Sat Aug 09, 2003 4:07 pm Post subject: ifplugd |
|
|
You might want to check-out ifplugd http://www.gentoo.org/dyn/pkgs/sys-apps/ifplugd.xml.
Its a great daemon - it polls the eth port to see if media is present, and if so, would bring up the interface; like windows. Problem solved -- great for laptops.
I think its a bit hacky for the user to press a key if the eth cable is not plugged in so that dhcpcd does not keep on scanning like a idiot for an IP to become available. |
|
Back to top |
|
|
azote Guru
Joined: 17 Sep 2002 Posts: 415
|
Posted: Wed Aug 13, 2003 7:13 pm Post subject: Re: ifplugd |
|
|
boobytrapped wrote: | You might want to check-out ifplugd http://www.gentoo.org/dyn/pkgs/sys-apps/ifplugd.xml.
Its a great daemon - it polls the eth port to see if media is present, and if so, would bring up the interface; like windows. Problem solved -- great for laptops.
I think its a bit hacky for the user to press a key if the eth cable is not plugged in so that dhcpcd does not keep on scanning like a idiot for an IP to become available. |
great tool I love it !!
and today a new version came out (ifplugd 0.16 )
with Better WLAN association detection, a monitor mode for checking the availability of network interfaces (for PCMCIA) _________________ contact me -> azote@mail.i2p
What do you want to emerge today?
if you think that a person is normal, it is because you do not know them well |
|
Back to top |
|
|
tank Tux's lil' helper
Joined: 28 Aug 2002 Posts: 116 Location: Virginia
|
Posted: Wed Aug 13, 2003 9:06 pm Post subject: |
|
|
I installed ifplugd using the ebuild in portage.
However it does not seem to run dhcpd when it brings up an eth0 |
|
Back to top |
|
|
Kasjopayer n00b
Joined: 11 May 2003 Posts: 48 Location: Switzerland
|
Posted: Thu Aug 14, 2003 12:37 pm Post subject: |
|
|
There's a workaround described in another thread, I will summarize it:
1. emerge ifplugd
2. emerge net-tools (if it isn't already emerged)
3. edit the net.ethX scripts as following:
https://bugs.gentoo.org/attachment.cgi?id=15471&action=view
(remove two lines, add one lines).
4. add in the config file /etc/conf.d/ifplugd the options "-a -mm" to ARGS:
Code: | ARGS="-f -u0 -d5 -w -a -mm" |
5. rc-update add ifplugd default
net-tools is needed, because it inclues mii. It scans wheter a cable is plugged in (while the interface isn't up - that's the reason for using it - therefore -mm). The second option -a goes in the same direction, it doesn't enable the interface automatically. Otherwise ifplugd won't work with the net.ethX scripts.
Maybe there's a better way to solve it, but it works finally.
BTW: the option "-d5" defines the delay from plugging out up to shutting down the interface. Default is 20 seconds, I set it down to 5 seconds.
I hope this helps!
Kasjopayer |
|
Back to top |
|
|
snis Tux's lil' helper
Joined: 03 Mar 2003 Posts: 93 Location: Stockholm, Sweden
|
Posted: Thu Aug 14, 2003 12:55 pm Post subject: |
|
|
...and another solution:
I read about this in a tread somewhere on the forum some time ago.
It requires sys-apps/mii-diag
And that you add the following lines to your net.ethX file:
Code: | else
if [ ! -n "$(which mii-tool 2> /dev/null)" -o -n "$(mii-tool ${IFACE} | grep "link ok")" ]
# if [ ! -n "$(which mii-diag 2> /dev/null)" -o -n "$(mii-diag --status ${IFACE} | grep "link bea
t" | grep "OK")" ]
then
/sbin/dhcpcd ${dhcp_args} ${IFACE} >/dev/null || {
retval=$?
eend ${retval} "dhcpcd failed to bring up ${IFACE}"
return ${retval}
}
else
eend 2 "No ethernet link on ${IFACE} detected - Network Not Initialized"
return 2
fi
fi |
this is how my 'start' section looks like in /etc/init.d/net.eth0
Code: | start() {
local retval=0
setup_env
checkconfig || return 1
ebegin "Bringing ${IFACE} up"
if [ "${iface_IFACE}" != "dhcp" ]
then
/sbin/ifconfig ${IFACE} ${iface_IFACE} >/dev/null || {
retval=$?
eend ${retval} "Failed to bring ${IFACE} up"
return ${retval}
}
# ifconfig do not always return failure ..
/sbin/ifconfig ${IFACE} &> /dev/null || {
retval=$?
eend ${retval} "Failed to bring ${IFACE} up"
return ${retval}
}
else
if [ ! -n "$(which mii-tool 2> /dev/null)" -o -n "$(mii-tool ${IFACE} | grep "link ok")" ]
# if [ ! -n "$(which mii-diag 2> /dev/null)" -o -n "$(mii-diag --status ${IFACE} | grep "link bea
t" | grep "OK")" ]
then
/sbin/dhcpcd ${dhcp_args} ${IFACE} >/dev/null || {
retval=$?
eend ${retval} "dhcpcd failed to bring up ${IFACE}"
return ${retval}
}
else
eend 2 "No ethernet link on ${IFACE} detected - Network Not Initialized"
return 2
fi
fi
if [ -n "${alias_IFACE}" ]
then
local x=""
local num=0
local aliasbcast=""
local aliasnmask=""
ebegin " Adding aliases"
for x in ${alias_IFACE}
do
aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')
"
if [ -n "${aliasbcast}" ]
then
aliasbcast="broadcast ${aliasbcast}"
fi
aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"
if [ -n "${aliasnmask}" ]
then
aliasnmask="netmask ${aliasnmask}"
fi
ebegin " ${IFACE}:${num}"
/sbin/ifconfig ${IFACE}:${num} ${x} \
${aliasbcast} ${aliasnmask} >/dev/null
num=$((num + 1))
eend 0
done
save_options "alias" "${alias_IFACE}"
fi
if [ -n "${inet6_IFACE}" ]
then
local x=""
ebegin " Adding inet6 addresses"
for x in ${inet6_IFACE}
do
ebegin " ${IFACE} inet6 add ${x}"
/sbin/ifconfig ${IFACE} inet6 add ${x} >/dev/null
eend 0
done
save_options "inet6" "${inet6_IFACE}"
fi
if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
then
ebegin " Setting default gateway"
# First delete any existing routes if it was setup by kernel ..
/sbin/route del default dev ${gateway%/*} &>/dev/null
/sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
netmask 0.0.0.0 metric 1 >/dev/null || {
local error=$?
ifconfig ${IFACE} down &>/dev/null
eend ${error} "Failed to bring ${IFACE} up"
stop
return ${error}
}
eend 0
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel
if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
} |
It works for me, I'm only using it on eth0 since I unplugg my wireless card if I'm not using it. |
|
Back to top |
|
|
Sven Vermeulen Retired Dev
Joined: 29 Aug 2002 Posts: 1345 Location: Mechelen, Belgium
|
Posted: Thu Aug 14, 2003 1:25 pm Post subject: |
|
|
I just set the time-out value for dhcp to 5 seconds. If the DHCP server doesn't reply in 5 seconds, I know (1) something is wrong, or (2) there is no DHCP to request to (i.e. no medium connection).
Edit /etc/conf.d/net and set the dhcpcd_args so it contains "-t 5". |
|
Back to top |
|
|
Garbz Apprentice
Joined: 02 Jul 2003 Posts: 260 Location: Brisbane, Australia
|
Posted: Fri Aug 15, 2003 7:50 am Post subject: |
|
|
I've had an overly congested network at times, dhcp took way longer than 5 seconds to aquire I know it shouldn't _________________ Every begining is another begining's end. |
|
Back to top |
|
|
StinkyLou n00b
Joined: 13 Aug 2003 Posts: 11
|
Posted: Fri Aug 15, 2003 8:48 pm Post subject: |
|
|
Kasjopayer,
I followed your instructions, but I'm still having trouble.
Despite the fact that ifplugd loads on boot (before eth0 starts), eth0 still pauses for several minutes. I think I did everthing as you suggested, but I might have made a mistake. I have one concern in particular: when editing net.eth0, the two lines I removed and the line I added were from the stop() section of the file. Was that correct? I'd be happy to post my net.eth0 if you think that would be helpful.
I appreciate any input you can offer.
StinkyLou |
|
Back to top |
|
|
Garbz Apprentice
Joined: 02 Jul 2003 Posts: 260 Location: Brisbane, Australia
|
Posted: Sun Aug 17, 2003 1:22 am Post subject: |
|
|
yes the net.eth0 modification is correct.
Since ifplugd loads at boot and automatically handles the eth connection you should:
rc-update del net.eth0 default
since ifplugd will start it anyway when a cable is present.
The only problem with this method is that if a program which is dependant on on net.eth0 (and can't run without it i.e. mounting a remote filesystem) will start anyway and fail at boot.
As far as i've messed with it anyway. _________________ Every begining is another begining's end. |
|
Back to top |
|
|
StinkyLou n00b
Joined: 13 Aug 2003 Posts: 11
|
Posted: Sun Aug 17, 2003 5:08 am Post subject: |
|
|
Garbz,
Quote: | Since ifplugd loads at boot and automatically handles the eth connection you should:
rc-update del net.eth0 default |
That did it--thanks!!! I never would have come up with that on my own.
Keep on keepin' on.
StinkyLou |
|
Back to top |
|
|
Garbz Apprentice
Joined: 02 Jul 2003 Posts: 260 Location: Brisbane, Australia
|
Posted: Mon Aug 18, 2003 12:29 am Post subject: |
|
|
lol ur welcome. _________________ Every begining is another begining's end. |
|
Back to top |
|
|
BlackBart Apprentice
Joined: 07 Oct 2002 Posts: 252
|
Posted: Mon Aug 18, 2003 1:42 am Post subject: |
|
|
I solved this by grepping he cardmanager stab file to see if my network card was installed. This won't work if you have a built in ethernet though. |
|
Back to top |
|
|
|