Skip to content

Commit

Permalink
handle multiple NIC environments
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Oct 28, 2017
1 parent 8c9356f commit 3e434d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/get-boot-info
Expand Up @@ -75,14 +75,14 @@ setnet() {
# determine the name of the default network interface
# try several times if dhclient needs some more time
local i=0
NIC1=$(ip route | awk '/^default/ {print $5}')
NIC1=$(ip route | awk '/^default/ {print $5}'|head -1)
while [ ! "$NIC1" -a $i -lt 8 ]; do
sleep 2
NIC1=$(ip route | awk '/^default/ {print $5}')
NIC1=$(ip route | awk '/^default/ {print $5}'|head -1)
(( i += 1 ))
done
if [ -z "$NIC1" ]; then
NIC1=$(ip route | awk '/ dev / {print $3}')
NIC1=$(ip route | awk '/ dev / {print $3}'|head -1)
fi

read IPADDR NETMASK BROADCAST dummy<<<$(ifdata -p $dev)
Expand Down
2 changes: 1 addition & 1 deletion lib/task_inventory
Expand Up @@ -24,7 +24,7 @@ inventory() {
echo "CPU: $cpuname"
echo "Number of CPU/Cores: $ncpu"

nic1=$(ip route | awk '/^default/ {print $5}')
nic1=$(ip route | awk '/^default/ {print $5}'|head -1)
mac1=$(< /sys/class/net/$nic1/address)
echo "Network interface: $nic1"
echo "MAC address: $mac1"
Expand Down

0 comments on commit 3e434d0

Please sign in to comment.