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