home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.jcu.edu.au
/
2014.06.ftp.jcu.edu.au.tar
/
ftp.jcu.edu.au
/
v6.3.2b
/
SWBD63
/
fabos-6.3.2b-10.ppc.rpm
/
fabos-6.3.2b.10.cpio.gz
/
fabos-6.3.2b.10.cpio
/
fabos
/
cliexec
/
ifmodeshow
< prev
next >
Wrap
Text File
|
2010-11-10
|
2KB
|
100 lines
#!/bin/bash
#
# Emulate the ifModeShow command on the 4.0 Linux-based switches.
#
SWBD=`/sbin/sin | /bin/sed -n -e 's/^.\+\(SWBD\)\([[:digit:]]\{1,\}\).\+$/\2/gp' 2> /dev/null`
IFACE=$1
if [ "$IFACE" = "" ]; then
echo "Usage: ifModeShow <interface>"
echo "Example: ifModeShow \"eth0\""
exit 1
fi
# bonding enable only on zentron
if [ $SWBD = 62 -o $SWBD = 77 ]; then
if [ "$IFACE" != "eth0" ] && [ "$IFACE" != "eth3" ] \
&& [ "$IFACE" != "bond0" ]; then
echo "ifModeShow can only be used with eth0, eth3 or bond0."
exit 1
fi
else
if [ "$IFACE" != "eth0" ]; then
echo "ifModeShow can only be used with eth0."
exit 1
fi
fi
if [ "$IFACE" = "bond0" ]; then
/bin/cat /proc/net/bonding/bond0 | /bin/grep "Currently Active Slave"
exit 0
fi
# populate $1,$2,$3,$4,$5,$6 with output of ethmode
set -- `/fabos/libexec/ethmode "$IFACE"`
# assign some more readable variable names
AUTONEG=$2
LINK=$5
CURRENT=$6
# strings reported to user in forced mode
FORCED_HALF="half duplex"
FORCED_FULL="full duplex"
FORCED_10="10 Mbit"
FORCED_100="100 Mbit"
if [ "$LINK" -eq 0 ]; then
LINK_STRING="no link"
else
LINK_STRING="link ok"
fi
if [ "$AUTONEG" -eq 0 ]; then
if [ "$CURRENT" -eq 1 ]; then
FORCED_DUPLEX=$FORCED_HALF
FORCED_SPEED=$FORCED_10
elif [ "$CURRENT" -eq 2 ]; then
FORCED_DUPLEX=$FORCED_FULL
FORCED_SPEED=$FORCED_10
elif [ "$CURRENT" -eq 4 ]; then
FORCED_DUPLEX=$FORCED_HALF
FORCED_SPEED=$FORCED_100
elif [ "$CURRENT" -eq 8 ]; then
FORCED_DUPLEX=$FORCED_FULL
FORCED_SPEED=$FORCED_100
else
FORCED_SPEED="speed undetermined"
FORCED_DUPLEX="duplex undetermined"
fi
echo "Link mode:" $FORCED_SPEED"," $FORCED_DUPLEX"," $LINK_STRING
else
if [ "$LINK" -eq 0 ]; then
echo "Link mode:" $LINK_STRING
else
if [ "$CURRENT" -eq 1 ]; then
AUTO_MODE="10baseT-HD"
elif [ "$CURRENT" -eq 2 ]; then
AUTO_MODE="10baseT-FD"
elif [ "$CURRENT" -eq 4 ]; then
AUTO_MODE="100baseTx-HD"
elif [ "$CURRENT" -eq 8 ]; then
AUTO_MODE="100baseTx-FD"
elif [ "$CURRENT" -eq 16 ]; then
AUTO_MODE="1000baseT-HD"
elif [ "$CURRENT" -eq 32 ]; then
AUTO_MODE="1000baseT-FD"
else
AUTO_MODE="speed and duplex undetermined"
fi
echo "Link mode: negotiated" $AUTO_MODE"," $LINK_STRING
fi
fi
S=$(/sbin/ifconfig "$IFACE")
S=${S#*HWaddr }
S=${S%% *}
echo MAC Address: $S
exit 0