#!/bin/sh
. /scripts/functions

wait_ethernet() {
  local netdevwait=60
  echo "Waiting up to ${netdevwait} secs for any ethernet to become available"
  while [ "$(time_elapsed)" -lt "$netdevwait" ]; do
    for device in /sys/class/net/* ; do
      if [ -f "$device/type" ]; then
        current_type=$(cat "$device/type")
        if [ "${current_type}" = "1" ]; then
          echo "Device ${device} found"
          return
        fi
      fi
    done
    sleep 1
  done
}

wait_ethernet
