59 lines
1.3 KiB
Bash
Executable file
59 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
source scan-netdev
|
|
source test-variables
|
|
|
|
check_listed_mac () {
|
|
if [[ -n $LISTED_MAC ]] ; then
|
|
echo "$RES_ERROR: $BLD$MAC$OFF belongs to $LISTED_DEV"
|
|
fi
|
|
}
|
|
|
|
DEVICES=`grep -v 'lo:' /proc/net/dev \
|
|
| grep -v '\.[0-9]\+:' \
|
|
| grep ':' \
|
|
| cut -d ':' -f 1`
|
|
|
|
for DEV in $DEVICES ; do
|
|
ip link set $DEV up
|
|
done
|
|
sleep 1
|
|
while [[ 1 ]] ; do
|
|
clear
|
|
date
|
|
for DEV in $DEVICES ; do
|
|
MAC=`cat /sys/class/net/$DEV/address`
|
|
LISTED=`grep $DEV $OUTPUT_DIR/netdev.lst`
|
|
MATCHING_MAC=`echo $LISTED | grep $MAC`
|
|
LISTED_MAC=`grep $MAC $OUTPUT_DIR/netdev.lst `
|
|
LISTED_DEV=`echo $LISTED_MAC | cut -d ' ' -f 1`
|
|
LINKING=`cat /sys/class/net/$DEV/operstate`
|
|
if [[ "$LINKING" == "up" ]] ; then
|
|
echo -n "$GRN$DEV$OFF "
|
|
else
|
|
echo -n "$RED$DEV$OFF "
|
|
fi
|
|
if [[ -z $LISTED ]] ; then
|
|
echo "$MAC $RES_ERROR: Device $BLD$DEV$OFF not listed"
|
|
check_listed_mac
|
|
elif [[ -z $MATCHING_MAC ]] ; then
|
|
echo -n "$RES_ERROR: Mac addres $BLD$MAC$OFF "
|
|
echo "not matching for $BLD$DEV$OFF"
|
|
check_listed_mac
|
|
else
|
|
echo "$MAC $LINKING"
|
|
fi
|
|
done
|
|
for DEV in \
|
|
`sed 's/#.*$//' $OUTPUT_DIR/netdev.lst | cut -d ' ' -f 1`
|
|
do
|
|
STILL_THERE=`grep $DEV /proc/net/dev `
|
|
if [[ -z $STILL_THERE ]] ; then
|
|
echo "$BLD$DEV$OFF $RES_ERROR: Device missing"
|
|
#check_listed_mac
|
|
fi
|
|
done
|
|
sleep 2
|
|
done
|
|
|
|
|