#!/bin/bash
#
# This script checks the ethernet transceiver for a link.  It uses
# mii-tool (you can find it in the Debian package net-tools).  The
# test is skipped if mii-tool is not available or mii-tool does not
# support this card.
#
# It is particularly useful with a machine with a built in ethernet
# card.  I use it on a Thinkpad T20.
#
# Chris Halls <chris.halls@nikocity.de>, August 2001

DEVICE=${1:-"eth0"}
MIITOOL=/sbin/mii-tool

if [ -x $MIITOOL ] ; then
    if STATUS=`$MIITOOL $DEVICE` ; then

        if echo "$STATUS" | grep -q "no link" ; then
            LOCATED=1
            echo disconnected >>iwillbe
        fi
    
    fi
fi
