Ethernet cable check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



is there an official way to check for the presence of an ethernet cable for
an interface? If I config an interface with ONBOOT=yes but there is no cable
plugged in, it nevertheless configures the interface, which might later
startups such as sendmail waste a lot of time trying to access the
nonfunctional network. It also may keep default routes around that get in
the way if I later fire up the wireless interface. There is a program
mii-tool that can tell you whether the link is up:

csh> mii-tool eth0
eth0: negotiated 100baseTx-FD flow-control, link ok

so I tried to use this. Here's the hack I am using now (on an Asus M68Ne).
My ifcfg-eth0 looks like this (in part)

 DEVICE=eth0
 BOOTPROTO=none
 IPADDR=192.168.100.51
 TYPE=Ethernet
 USERCTL=no
 ONBOOT=`if mii-tool $DEVICE | egrep -q 'link ok' ; then echo yes ; else
echo no; fi`

inside ifup, this file is sourced, so all is well. However, inside
init.d/network there is some trickery; these ifcfg-* files are not sourced,
but it attempts to parse them. This made my first attempt fail:

 if mii-tool eth0 | egrep -q 'link ok' ; then
 ONBOOT=yes
 else
 ONBOOT=no
 fi

init.d/network greps for "ONBOOT=no" and if it finds it, skips the
interface. My new version no longer contains this substring, so it seems to
work, but I wonder whether there isn't a more standard solution.

Roman Maeder

-- 
The most aptly named computer book: "Windows for Dummies"


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux