File: testmii

package info (click to toggle)
whereami 0.3.37
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: sh: 1,094; perl: 524; makefile: 24
file content (33 lines) | stat: -rwxr-xr-x 847 bytes parent folder | download | duplicates (7)
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
33
#!/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