Skip to content

Commit

Permalink
Refactoring(netdev-model-list): strongbash compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
strizhechenko committed Dec 24, 2018
1 parent 1e75627 commit 5347c12
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions utils/nic-model-list → utils/netdev-model-list
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ if [ "{1:-}" == '--help' ]; then
fi

rx_buf() {
set -e
# skip strongbash034
ethtool -g "$1" 2>/dev/null | tac | grep "RX:" | egrep -o "[0-9]+" | tr '\n' '/'| sed 's|/$||g'
return 0
}

show_device() {
local eth="$1"
local id="$2"
is_vlan=0
if ethtool -i "$eth" | grep -q '802.1Q VLAN Support'; then
is_vlan=1
fi
local is_vlan=0
local output
output="$(ethtool -i "$eth")"
grep -q '802.1Q VLAN Support' <<< "$output" && is_vlan=1
if [ "$is_vlan" = 0 ]; then

echo "$eth: $(grep -w $id /tmp/lspci.tmp) rx: $(rx_buf "$eth")"
echo "$eth: $(grep -w "$id" /tmp/lspci.tmp) rx: $(rx_buf "$eth")"
else
echo "$eth: VLAN interface"
fi
Expand All @@ -35,8 +36,8 @@ show_device() {
main() {
local eth
local id
for eth in $(egrep -o "$DEVICE_REGEX" /proc/net/dev | sort -u); do
for id in $(ethtool -i "$eth" | grep bus-info | sed 's/.*0000:https://'); do
for eth in $(egrep -o "$DEVICE_REGEX" /proc/net/dev | sort -u || true); do
for id in $(ethtool -i "$eth" | grep bus-info | sed 's/.*0000:https://' || true); do
show_device "$eth" "$id"
done
done
Expand Down

0 comments on commit 5347c12

Please sign in to comment.