Merge "Handle failure of carrier check in dhcp-all-interfaces.sh"

This commit is contained in:
Jenkins 2017-01-13 20:11:20 +00:00 committed by Gerrit Code Review
commit 1f75aea634

View File

@ -38,7 +38,7 @@ function serialize_me() {
} }
function get_if_link() { function get_if_link() {
cat /sys/class/net/${1}/carrier cat /sys/class/net/${1}/carrier || echo 0
} }
function enable_interface() { function enable_interface() {
@ -87,11 +87,11 @@ function inspect_interface() {
elif [ "$mac_addr_type" != "0" ]; then elif [ "$mac_addr_type" != "0" ]; then
echo "Device has generated MAC, skipping." echo "Device has generated MAC, skipping."
else else
ip link set dev $interface up &>/dev/null
local has_link local has_link
local tries local tries
for ((tries = 0; tries < 20; tries++)); do for ((tries = 0; tries < 20; tries++)); do
# Need to set the link up on each iteration
ip link set dev $interface up &>/dev/null
has_link=$(get_if_link $interface) has_link=$(get_if_link $interface)
[ "$has_link" == "1" ] && break [ "$has_link" == "1" ] && break
sleep 1 sleep 1