Dropping option to filter by label as newer versions of 'ip' give another result (no output)

This commit is contained in:
Michael Boelen 2021-07-08 15:18:20 +02:00
parent 5d96098a82
commit 7867759750
No known key found for this signature in database
GPG Key ID: 26141F77A09D7F04

View File

@ -1015,17 +1015,11 @@
HOSTID_GEN="linux-ip-interface-eth0" HOSTID_GEN="linux-ip-interface-eth0"
else else
# If eth0 does not exist, which is also common, then trying the next option: # If eth0 does not exist, which is also common, then trying the next option:
# 1) First fetch all links that are UP and start with 'en' # 1) First fetch all links that are UP
# 2) Filter entries that have a MAC address and filter out Docker related MAC addresses starting with '02:42:' # 2) Filter entries that have a MAC address and filter out Docker related MAC addresses starting with '02:42:'
# 3) Convert everything to lowercase # 3) Convert everything to lowercase
# 4) Sort the entries, so that the output is more predictable between runs when the same interfaces are available # 4) Sort the entries, so that the output is more predictable between runs when the same interfaces are available
# 5) Select first entry # 5) Select first entry
FIND=$(${IPBINARY} -family link addr show up label 'en*' 2> /dev/null | awk '{if($1=="link/ether" && $2 !~ "^02:42:"){print $2}}' | tr '[:upper:]' '[:lower:]' | sort | head -1)
if HasData "${FIND}"; then
HOSTID_GEN="linux-ip-interface-up-en"
else
LogText "Info: selecting interfaces by label 'en*' did not return results, trying without it"
# Try again, without specifying a preferred interface name
FIND=$(${IPBINARY} -family link addr show up 2> /dev/null | awk '{if($1=="link/ether" && $2 !~ "^02:42:"){print $2}}' | tr '[:upper:]' '[:lower:]' | sort | head -1) FIND=$(${IPBINARY} -family link addr show up 2> /dev/null | awk '{if($1=="link/ether" && $2 !~ "^02:42:"){print $2}}' | tr '[:upper:]' '[:lower:]' | sort | head -1)
if HasData "${FIND}"; then if HasData "${FIND}"; then
HOSTID_GEN="linux-ip-interface-up-other" HOSTID_GEN="linux-ip-interface-up-other"
@ -1034,7 +1028,6 @@
fi fi
fi fi
fi fi
fi
# Finally try ifconfig # Finally try ifconfig
if IsEmpty "${FIND}" && [ -n "${IFCONFIGBINARY}" ]; then if IsEmpty "${FIND}" && [ -n "${IFCONFIGBINARY}" ]; then