[Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
Nicolas Cavallari
nicolas.cavallari at green-communications.fr
Thu Oct 29 08:08:10 UTC 2015
On 28/10/2015 16:59, Jérôme Pouiller wrote:
> This patch has same purpose than 49964858f45d2243c513e6d362e992ad89ec7a45:
>
> On some machines, the network interface is slow to appear. For example,
> on the Raspberry Pi, the network interface eth0 is an ethernet-over-USB,
> and our standard boot process is too fast, so our network startup script
> is called before the USB bus is compeltely enumerated, thus it can't
> configure eth0.
>
> Closes #8116.
>
> However, it use an optionnal ifupdown hook instead of an initscript.
>
> Signed-off-by: Jérôme Pouiller <jezz at sysmic.org>
> ---
> system/skeleton/etc/network/if-pre-up.d/wait_iface | 28 ++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
> create mode 100755 system/skeleton/etc/network/if-pre-up.d/wait_iface
>
> diff --git a/system/skeleton/etc/network/if-pre-up.d/wait_iface b/system/skeleton/etc/network/if-pre-up.d/wait_iface
> new file mode 100755
> index 0000000..4f0866b
> --- /dev/null
> +++ b/system/skeleton/etc/network/if-pre-up.d/wait_iface
> @@ -0,0 +1,28 @@
> +#!/bin/sh
> +
> +# In case we have a slow-to-appear interface (e.g. eth-over-USB),
> +# and we need to configure it, wait until it appears, but not too
> +# long either. IF_WAIT_DELAY is in seconds.
> +
> +if [ "${IF_WAIT_DELAY}" ]; then
> +
> + printf "Waiting for interface %s to appear" "${IFACE}"
I think we shouldn't print this scary message when the interface already
exist in the first place... I was suggesting to only do it if
VERBOSITY=1 but busybox does not support that.
> + while [ ${IF_WAIT_DELAY} -gt 0 ]; do
> +
> + if [ -e "/sys/class/net/${IFACE}" ]; then
> +
> + printf " yes\n"
So this prints:
"Waiting for interface dummy0 to appear..... yes"
or
"Waiting for interface dummy0 to appear............... no"
We should maybe just print a new line on success and an explicit error
message on failure.
> + exit 0
> +
> + fi
> + sleep 1
> + printf "."
> +
> + : $((IF_WAIT_DELAY -= 1))
> +
> + done
> + printf " no.\n"
> + exit 1
> +
> +fi
> +
>
More information about the buildroot
mailing list