wait_iface 576 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. # In case we have a slow-to-appear interface (e.g. eth-over-USB),
  3. # and we need to configure it, wait until it appears, but not too
  4. # long either. IF_WAIT_DELAY is in seconds.
  5. if [ "${IF_WAIT_DELAY}" -a ! -e "/sys/class/net/${IFACE}" ]; then
  6. printf "Waiting for interface %s to appear" "${IFACE}"
  7. while [ ${IF_WAIT_DELAY} -gt 0 ]; do
  8. if [ -e "/sys/class/net/${IFACE}" ]; then
  9. printf "\n"
  10. exit 0
  11. fi
  12. sleep 1
  13. printf "."
  14. : $((IF_WAIT_DELAY -= 1))
  15. done
  16. printf " timeout!\n"
  17. exit 1
  18. fi