All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/3] Alternative way to wait interfaces on bootup
@ 2015-10-28 15:59 Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 1/3] Revert "package/initscripts: S40network: wait for network interfaces to appear" Jérôme Pouiller
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jérôme Pouiller @ 2015-10-28 15:59 UTC (permalink / raw)
  To: buildroot

As discussed here:

   http://lists.busybox.net/pipermail/buildroot/2015-October/142329.html

J?r?me Pouiller (3):
  Revert "package/initscripts: S40network: wait for network interfaces
    to appear"
  skeleton: optionally wait for network interfaces to appear
  skeleton: wait interface to appear if dhcp is enabled

 package/initscripts/init.d/S40network              | 29 ----------------------
 package/skeleton/skeleton.mk                       |  1 +
 system/skeleton/etc/network/if-pre-up.d/wait_iface | 28 +++++++++++++++++++++
 3 files changed, 29 insertions(+), 29 deletions(-)
 create mode 100755 system/skeleton/etc/network/if-pre-up.d/wait_iface

-- 
2.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 1/3] Revert "package/initscripts: S40network: wait for network interfaces to appear"
  2015-10-28 15:59 [Buildroot] [PATCH 0/3] Alternative way to wait interfaces on bootup Jérôme Pouiller
@ 2015-10-28 15:59 ` Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 3/3] skeleton: wait interface to appear if dhcp is enabled Jérôme Pouiller
  2 siblings, 0 replies; 12+ messages in thread
From: Jérôme Pouiller @ 2015-10-28 15:59 UTC (permalink / raw)
  To: buildroot

This reverts commit 49964858f45d2243c513e6d362e992ad89ec7a45. It is
going to be replaced with an ifup hook in next patch.

Signed-off-by: J?r?me Pouiller <jezz@sysmic.org>
---
 package/initscripts/init.d/S40network | 29 -----------------------------
 1 file changed, 29 deletions(-)

diff --git a/package/initscripts/init.d/S40network b/package/initscripts/init.d/S40network
index a8d7c5d..7b11d8b 100755
--- a/package/initscripts/init.d/S40network
+++ b/package/initscripts/init.d/S40network
@@ -6,37 +6,8 @@
 # Debian ifupdown needs the /run/network lock directory
 mkdir -p /run/network
 
-# 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. WAIT_DELAY is in seconds.
-WAIT_DELAY=15
-
-wait_for_interfaces() {
-	IFACES=$(awk '/^auto/ { print $2 }' /etc/network/interfaces)
-	[ -n "$IFACES" ] || return
-
-	printf "Waiting for network interfaces to appear"
-
-	for i in $(seq $WAIT_DELAY); do
-	    for IFACE in $IFACES; do
-		if [ ! -e "/sys/class/net/$IFACE" ]; then
-		    printf "."
-		    sleep 1
-		    continue 2
-		fi
-	    done
-
-	    printf " ok\n"; return
-	done
-
-	printf " timeout\n"
-	exit 1
-}
-
 case "$1" in
   start)
-	wait_for_interfaces
-
  	echo "Starting network..."
 	/sbin/ifup -a
 	;;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 15:59 [Buildroot] [PATCH 0/3] Alternative way to wait interfaces on bootup Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 1/3] Revert "package/initscripts: S40network: wait for network interfaces to appear" Jérôme Pouiller
@ 2015-10-28 15:59 ` Jérôme Pouiller
  2015-10-28 17:46   ` Yann E. MORIN
  2015-10-29  8:08   ` Nicolas Cavallari
  2015-10-28 15:59 ` [Buildroot] [PATCH 3/3] skeleton: wait interface to appear if dhcp is enabled Jérôme Pouiller
  2 siblings, 2 replies; 12+ messages in thread
From: Jérôme Pouiller @ 2015-10-28 15:59 UTC (permalink / raw)
  To: buildroot

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@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}"
+    while [ ${IF_WAIT_DELAY} -gt 0 ]; do
+
+        if [ -e "/sys/class/net/${IFACE}" ]; then
+
+            printf " yes\n"
+            exit 0
+
+        fi
+        sleep 1
+        printf "."
+
+        : $((IF_WAIT_DELAY -= 1))
+
+    done
+    printf " no.\n"
+    exit 1
+
+fi
+
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 3/3] skeleton: wait interface to appear if dhcp is enabled
  2015-10-28 15:59 [Buildroot] [PATCH 0/3] Alternative way to wait interfaces on bootup Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 1/3] Revert "package/initscripts: S40network: wait for network interfaces to appear" Jérôme Pouiller
  2015-10-28 15:59 ` [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear Jérôme Pouiller
@ 2015-10-28 15:59 ` Jérôme Pouiller
  2 siblings, 0 replies; 12+ messages in thread
From: Jérôme Pouiller @ 2015-10-28 15:59 UTC (permalink / raw)
  To: buildroot

wait-delay hook is enabled only if wait-delay property appears in
/etc/network/interfaces. This patch enable it automaticaly when
interface is configured through DHCP at bootup. However, if user choose
to write /etc/network/interface himself, he have to explicitly
set wait-delay.

Signed-off-by: J?r?me Pouiller <jezz@sysmic.org>
---
 package/skeleton/skeleton.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/skeleton/skeleton.mk b/package/skeleton/skeleton.mk
index 920d3b4..d1b797d 100644
--- a/package/skeleton/skeleton.mk
+++ b/package/skeleton/skeleton.mk
@@ -89,6 +89,7 @@ define SET_NETWORK_DHCP
 		echo ;                                               \
 		echo "auto $(NETWORK_DHCP_IFACE)";                   \
 		echo "iface $(NETWORK_DHCP_IFACE) inet dhcp";        \
+		echo "	wait-delay 15";                              \
 	) >> $(TARGET_DIR)/etc/network/interfaces
 endef
 endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 15:59 ` [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear Jérôme Pouiller
@ 2015-10-28 17:46   ` Yann E. MORIN
  2015-10-28 20:21     ` Jérôme Pouiller
  2015-10-29  8:08   ` Nicolas Cavallari
  1 sibling, 1 reply; 12+ messages in thread
From: Yann E. MORIN @ 2015-10-28 17:46 UTC (permalink / raw)
  To: buildroot

J?r?me, All,

On 2015-10-28 16:59 +0100, J?r?me Pouiller spake thusly:
> 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@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
> +

Please drop the empty lines.

Also, I would have preferred patches 2 & 3 to be folded into a single
patch. I don't really understand how it all works:

  - does the busybox ifup-down and full-fledged ifup-down support
    wait-delay?
  - I looked at man 5 interfaces, and there is no mention of wait-delay,
  - I don't see how 'wait-delay' translates to 'wait_iface'
  - I guess 'wait-delay' is made an environment variable IF_WAIT_DELAY
    before the script is run, but I'd have preferred explanations rather
    than having to guess.

Care to shed some light, please?

Otherwise, the idea looks fine to me. Thanks! :-)

Regards,
Yann E. MORIN.

> +    printf "Waiting for interface %s to appear" "${IFACE}"
> +    while [ ${IF_WAIT_DELAY} -gt 0 ]; do
> +
> +        if [ -e "/sys/class/net/${IFACE}" ]; then
> +
> +            printf " yes\n"
> +            exit 0
> +
> +        fi
> +        sleep 1
> +        printf "."
> +
> +        : $((IF_WAIT_DELAY -= 1))
> +
> +    done
> +    printf " no.\n"
> +    exit 1
> +
> +fi
> +
> -- 
> 2.1.4
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 17:46   ` Yann E. MORIN
@ 2015-10-28 20:21     ` Jérôme Pouiller
  2015-10-28 21:37       ` Yann E. MORIN
  0 siblings, 1 reply; 12+ messages in thread
From: Jérôme Pouiller @ 2015-10-28 20:21 UTC (permalink / raw)
  To: buildroot

Hello Yann,

On Wednesday 28 October 2015 18:46:53 Yann E. MORIN wrote:
> J?r?me, All,
> 
> On 2015-10-28 16:59 +0100, J?r?me Pouiller spake thusly:
[...]
> Please drop the empty lines.
There were empty lines in original patch ;-).

> Also, I would have preferred patches 2 & 3 to be folded into a single
> patch. 
ok.

> I don't really understand how it all works:
> 
>   - does the busybox ifup-down and full-fledged ifup-down support
>     wait-delay?
Yes, both.

>   - I looked at man 5 interfaces, and there is no mention of
> wait-delay,

I have found documentation related to if-*.d scripts in section called 
"IFACE OPTIONS" of interfaces(5) of my debian.


>   - I don't see how 'wait-delay' translates to 'wait_iface'

From interfaces(5):

  "Additionally, all options given in an interface definition stanza are 
exported to the environment in upper case  with  "IF_"  prepended  and  
with hyphens converted to underscores and non-alphanumeric characters 
discarded."


>   - I guess 'wait-delay' is made an environment variable IF_WAIT_DELAY
> before the script is run, but I'd have preferred explanations rather
> than having to guess.
> 
> Care to shed some light, please?

Regards,

-- 
J?r?me Pouiller, Sysmic
Embedded Linux specialist
http://www.sysmic.fr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 20:21     ` Jérôme Pouiller
@ 2015-10-28 21:37       ` Yann E. MORIN
  2015-10-28 21:51         ` Peter Korsgaard
  2015-10-29  7:53         ` Nicolas Cavallari
  0 siblings, 2 replies; 12+ messages in thread
From: Yann E. MORIN @ 2015-10-28 21:37 UTC (permalink / raw)
  To: buildroot

J?r?me, All,

On 2015-10-28 21:21 +0100, J?r?me Pouiller spake thusly:
> On Wednesday 28 October 2015 18:46:53 Yann E. MORIN wrote:
> > On 2015-10-28 16:59 +0100, J?r?me Pouiller spake thusly:
> [...]
> > Please drop the empty lines.
> There were empty lines in original patch ;-).

OK, I see. ;-)

Still, please drop them next time, please.

[--SNIP--]
> >   - I looked at man 5 interfaces, and there is no mention of
> > wait-delay,
> 
> I have found documentation related to if-*.d scripts in section called 
> "IFACE OPTIONS" of interfaces(5) of my debian.
> 
> >   - I don't see how 'wait-delay' translates to 'wait_iface'
> 
> From interfaces(5):
> 
>   "Additionally, all options given in an interface definition stanza are 
> exported to the environment in upper case  with  "IF_"  prepended  and  
> with hyphens converted to underscores and non-alphanumeric characters 
> discarded."

OK, thanks for the explanations. So there is no relation between the
'stanza' name and the script name, right?

Also, I read this in man 5 interfaces;

    When ifupdown is being called with the --all option, before doing
    anything to interfaces, if [sic] calls all the hook scripts (pre-up
    or down) with IFACE set to "--all", LOGICAL set to the current value
    of --allow parameter (or "auto" if it's  not set), ADDRFAM="meta"
    and METHOD="none". After all the interfaces have been brought up or
    taken down, the appropriate scripts (up or post-down) are executed.

Since S40network calls 'ifup -a' and you added a pre-up script, I guess
it should filter out the '--all' interface and exit early in that case.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 21:37       ` Yann E. MORIN
@ 2015-10-28 21:51         ` Peter Korsgaard
  2015-10-28 21:57           ` Yann E. MORIN
  2015-10-29  7:53         ` Nicolas Cavallari
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2015-10-28 21:51 UTC (permalink / raw)
  To: buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

Hi,

 > Also, I read this in man 5 interfaces;

 >     When ifupdown is being called with the --all option, before doing
 >     anything to interfaces, if [sic] calls all the hook scripts (pre-up
 >     or down) with IFACE set to "--all", LOGICAL set to the current value
 >     of --allow parameter (or "auto" if it's  not set), ADDRFAM="meta"
 >     and METHOD="none". After all the interfaces have been brought up or
 >     taken down, the appropriate scripts (up or post-down) are executed.

 > Since S40network calls 'ifup -a' and you added a pre-up script, I guess
 > it should filter out the '--all' interface and exit early in that case.

As far as I can see from the busybox implementation atleast, -a (all)
only causes it to run ifup/ifdown (with IFACE set to the interface name) for
each interface listed as auto, so it doesn't do the "--all" thing, but
the Debian variant does.

-- 
Venlig hilsen,
Peter Korsgaard 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 21:51         ` Peter Korsgaard
@ 2015-10-28 21:57           ` Yann E. MORIN
  2015-10-28 22:15             ` Peter Korsgaard
  0 siblings, 1 reply; 12+ messages in thread
From: Yann E. MORIN @ 2015-10-28 21:57 UTC (permalink / raw)
  To: buildroot

Peter, All,

On 2015-10-28 22:51 +0100, Peter Korsgaard spake thusly:
> >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
>  > Also, I read this in man 5 interfaces;
> 
>  >     When ifupdown is being called with the --all option, before doing
>  >     anything to interfaces, if [sic] calls all the hook scripts (pre-up
>  >     or down) with IFACE set to "--all", LOGICAL set to the current value
>  >     of --allow parameter (or "auto" if it's  not set), ADDRFAM="meta"
>  >     and METHOD="none". After all the interfaces have been brought up or
>  >     taken down, the appropriate scripts (up or post-down) are executed.
> 
>  > Since S40network calls 'ifup -a' and you added a pre-up script, I guess
>  > it should filter out the '--all' interface and exit early in that case.
> 
> As far as I can see from the busybox implementation atleast, -a (all)
> only causes it to run ifup/ifdown (with IFACE set to the interface name) for
> each interface listed as auto, so it doesn't do the "--all" thing, but
> the Debian variant does.

Since we already have the option to use the full-fledged ifup-down, we
should support the case where IFACE=--all in the script.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 21:57           ` Yann E. MORIN
@ 2015-10-28 22:15             ` Peter Korsgaard
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2015-10-28 22:15 UTC (permalink / raw)
  To: buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

Hi,

>> As far as I can see from the busybox implementation atleast, -a (all)
 >> only causes it to run ifup/ifdown (with IFACE set to the interface name) for
 >> each interface listed as auto, so it doesn't do the "--all" thing, but
 >> the Debian variant does.

 > Since we already have the option to use the full-fledged ifup-down, we
 > should support the case where IFACE=--all in the script.

Yes, agreed - My comment was for information only.

-- 
Venlig hilsen,
Peter Korsgaard 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 21:37       ` Yann E. MORIN
  2015-10-28 21:51         ` Peter Korsgaard
@ 2015-10-29  7:53         ` Nicolas Cavallari
  1 sibling, 0 replies; 12+ messages in thread
From: Nicolas Cavallari @ 2015-10-29  7:53 UTC (permalink / raw)
  To: buildroot

On 28/10/2015 22:37, Yann E. MORIN wrote:
> OK, thanks for the explanations. So there is no relation between the
> 'stanza' name and the script name, right?

None at all. ifupdown just run-parts /etc/if-$PHASE.d/ and the scripts
are responsible for not doing anything when they shouldn't.

> Also, I read this in man 5 interfaces;
> 
>     When ifupdown is being called with the --all option, before doing
>     anything to interfaces, if [sic] calls all the hook scripts (pre-up
>     or down) with IFACE set to "--all", LOGICAL set to the current value
>     of --allow parameter (or "auto" if it's  not set), ADDRFAM="meta"
>     and METHOD="none". After all the interfaces have been brought up or
>     taken down, the appropriate scripts (up or post-down) are executed.
> 
> Since S40network calls 'ifup -a' and you added a pre-up script, I guess
> it should filter out the '--all' interface and exit early in that case.

When run in this case, it will have no IF_WAIT_DELAY variable, so the
script will not do anything.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear
  2015-10-28 15:59 ` [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear Jérôme Pouiller
  2015-10-28 17:46   ` Yann E. MORIN
@ 2015-10-29  8:08   ` Nicolas Cavallari
  1 sibling, 0 replies; 12+ messages in thread
From: Nicolas Cavallari @ 2015-10-29  8:08 UTC (permalink / raw)
  To: buildroot

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@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
> +
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-10-29  8:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-28 15:59 [Buildroot] [PATCH 0/3] Alternative way to wait interfaces on bootup Jérôme Pouiller
2015-10-28 15:59 ` [Buildroot] [PATCH 1/3] Revert "package/initscripts: S40network: wait for network interfaces to appear" Jérôme Pouiller
2015-10-28 15:59 ` [Buildroot] [PATCH 2/3] skeleton: optionally wait for network interfaces to appear Jérôme Pouiller
2015-10-28 17:46   ` Yann E. MORIN
2015-10-28 20:21     ` Jérôme Pouiller
2015-10-28 21:37       ` Yann E. MORIN
2015-10-28 21:51         ` Peter Korsgaard
2015-10-28 21:57           ` Yann E. MORIN
2015-10-28 22:15             ` Peter Korsgaard
2015-10-29  7:53         ` Nicolas Cavallari
2015-10-29  8:08   ` Nicolas Cavallari
2015-10-28 15:59 ` [Buildroot] [PATCH 3/3] skeleton: wait interface to appear if dhcp is enabled Jérôme Pouiller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.