/usr/share/whereami/tests/testmii is in whereami 0.3.34-0.3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #!/bin/sh
#
# by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed
# for use under the GPL version 2
#
# Turn on execution tracing, for debugging...
[ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace
ifconfig $1 up
#
# Use apparently more reliable mii-tool...
if [ -x /sbin/mii-tool ] ; then
/sbin/mii-tool $1 2>&1 | grep "link ok" >/dev/null && exit 0
# Don't exit on failure unless we confirm that mii-tool was supported
# since it won't work on many modern Gb cards...
/sbin/mii-tool $1 2>&1 | grep "Operation not supported" >/dev/null || exit 1
fi
if [ -x /usr/sbin/ethtool ] ; then
# Fall back to ethtool, which can give false positives on this
/usr/sbin/ethtool $1 2>&1 | grep "Link detected: yes" >/dev/null && exit 0
fi
# Interface is not connected - bring it down to remove it from
# routing table
ifconfig $1 down
exit 1
|