Re: Getting boot not to hang if ethernet not plugged into modem
Cheryl Homiak wrote:
> Is there something one can put in /etc/network/interfaces or somewhere so
> that ethernet card coming up will be conditional. right now, if I boot on
> either my laptop or desktop with "auto" set for eth0 and the cable modem
> isn't connected to the ethernet card, the whole boot hangs for quite a
> while.
Which means eth0 is set to use DHCP, and you are waiting for the DHCP to
timeout. What you need is a script to run in a "pre-up" line to detect if
there is a connection on the NIC.
Several scripts have been posted to this list. I have a variant adapted from
one of them. It works for both wired and wireless NICs. For wired NICs, it
uses mii-tool to see if there is a connection on the cable. For wireless
NICs, it uses iwconfig to make sure the NIC supports wireless (meaning it's
plugged in - my wireless NIC is PCMCIA).
Just setup /etc/network/interfaces like this:
iface eth0 inet dhcp
pre-up /usr/local/bin/checknic.sh wired
For wireless NICs, replace "wired" with wireless. The script is posted at
the end of this message.
Adam
#!/bin/bash
# checknic.sh - Checks status of network connection
# Called by ifupdown in the pre-up section
# Usage: $0 (wired|wireless)
# Status statements
MIIACK="link ok"
WIFINACK="no wireless extensions"
# System programs
GREP="/bin/grep"
IFCONFIG="/sbin/ifconfig"
IWCONFIG="/sbin/iwconfig"
MIITOOL="/sbin/mii-tool"
# Test connection for link
$IFCONFIG $IFACE 0.0.0.0 > /dev/null 2>&1 || exit 1
case $1 in
wired)
(( `$MIITOOL $IFACE | $GREP -c "$MIIACK"` > 0 )) && exit 0
;;
wireless)
(( `$IWCONFIG $IFACE | $GREP -c "$WIFINACK"` < 1 )) && exit 0
;;
*)
exit 2
;;
esac
exit 1
Reply to: