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