* [PATCH 3/3] add function wait_for_route_ok
@ 2012-02-15 6:40 Dave Young
[not found] ` <20120215064029.GA30112-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Dave Young @ 2012-02-15 6:40 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Manually setuping nic through udev is not always done when
we want network access. Here add a function wait_for_route_ok to
wait and make sure the network is accesible
Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/99base/dracut-lib.sh | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 85d4925..c85a019 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -392,6 +392,17 @@ wait_for_if_up() {
return 1
}
+wait_for_route_ok() {
+ local cnt=0
+ while [ $cnt -lt 200 ]; do
+ li=$(ip route show)
+ [[ "$li" =~ "$1" ]] && return 0
+ sleep 0.1
+ cnt=$(($cnt+1))
+ done
+ return 1
+}
+
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {
--
1.7.7.5
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <20120215064029.GA30112-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>]
* Re: [PATCH 3/3] add function wait_for_route_ok [not found] ` <20120215064029.GA30112-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org> @ 2012-02-15 8:23 ` Harald Hoyer [not found] ` <4F3B6B9F.3070203-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Harald Hoyer @ 2012-02-15 8:23 UTC (permalink / raw) To: Dave Young; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA Am 15.02.2012 07:40, schrieb Dave Young: > Manually setuping nic through udev is not always done when > we want network access. Here add a function wait_for_route_ok to > wait and make sure the network is accesible > > Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > modules.d/99base/dracut-lib.sh | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh > index 85d4925..c85a019 100755 > --- a/modules.d/99base/dracut-lib.sh > +++ b/modules.d/99base/dracut-lib.sh > @@ -392,6 +392,17 @@ wait_for_if_up() { > return 1 > } > > +wait_for_route_ok() { > + local cnt=0 > + while [ $cnt -lt 200 ]; do > + li=$(ip route show) > + [[ "$li" =~ "$1" ]] && return 0 > + sleep 0.1 > + cnt=$(($cnt+1)) > + done > + return 1 > +} > + > # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>] > # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>] > nfsroot_to_var() { $ li=$(ip route show) $ [[ "$li" =~ "$1" ]] && echo OK dash: 6: [[: not found Please do not use "bash" syntax ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <4F3B6B9F.3070203-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 3/3] add function wait_for_route_ok [not found] ` <4F3B6B9F.3070203-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2012-02-16 1:15 ` Dave Young [not found] ` <4F3C58C3.6020103-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Dave Young @ 2012-02-16 1:15 UTC (permalink / raw) To: Harald Hoyer; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA On 02/15/2012 04:23 PM, Harald Hoyer wrote: > Am 15.02.2012 07:40, schrieb Dave Young: >> Manually setuping nic through udev is not always done when >> we want network access. Here add a function wait_for_route_ok to >> wait and make sure the network is accesible >> >> Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> --- >> modules.d/99base/dracut-lib.sh | 11 +++++++++++ >> 1 files changed, 11 insertions(+), 0 deletions(-) >> >> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh >> index 85d4925..c85a019 100755 >> --- a/modules.d/99base/dracut-lib.sh >> +++ b/modules.d/99base/dracut-lib.sh >> @@ -392,6 +392,17 @@ wait_for_if_up() { >> return 1 >> } >> >> +wait_for_route_ok() { >> + local cnt=0 >> + while [ $cnt -lt 200 ]; do >> + li=$(ip route show) >> + [[ "$li" =~ "$1" ]] && return 0 >> + sleep 0.1 >> + cnt=$(($cnt+1)) >> + done >> + return 1 >> +} >> + >> # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>] >> # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>] >> nfsroot_to_var() { > > > $ li=$(ip route show) > $ [[ "$li" =~ "$1" ]] && echo OK > dash: 6: [[: not found > > Please do not use "bash" syntax For this issue, similar with the wait_for_if_up, Probably when this scripts is called `ip route show` show nothing because there's still no route added. In this case we should not return 0 I will update the two patch like "[ -z "${li##*state UP*}" ]", and check [ -z "$li" ] as well for the nul case > -- > To unsubscribe from this list: send the line "unsubscribe initramfs" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Thanks Dave ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <4F3C58C3.6020103-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 3/3] add function wait_for_route_ok [not found] ` <4F3C58C3.6020103-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2012-02-16 1:39 ` Dave Young 0 siblings, 0 replies; 4+ messages in thread From: Dave Young @ 2012-02-16 1:39 UTC (permalink / raw) To: Harald Hoyer; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA On 02/16/2012 09:15 AM, Dave Young wrote: > On 02/15/2012 04:23 PM, Harald Hoyer wrote: > >> Am 15.02.2012 07:40, schrieb Dave Young: >>> Manually setuping nic through udev is not always done when >>> we want network access. Here add a function wait_for_route_ok to >>> wait and make sure the network is accesible >>> >>> Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >>> --- >>> modules.d/99base/dracut-lib.sh | 11 +++++++++++ >>> 1 files changed, 11 insertions(+), 0 deletions(-) >>> >>> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh >>> index 85d4925..c85a019 100755 >>> --- a/modules.d/99base/dracut-lib.sh >>> +++ b/modules.d/99base/dracut-lib.sh >>> @@ -392,6 +392,17 @@ wait_for_if_up() { >>> return 1 >>> } >>> >>> +wait_for_route_ok() { >>> + local cnt=0 >>> + while [ $cnt -lt 200 ]; do >>> + li=$(ip route show) >>> + [[ "$li" =~ "$1" ]] && return 0 >>> + sleep 0.1 >>> + cnt=$(($cnt+1)) >>> + done >>> + return 1 >>> +} >>> + >>> # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>] >>> # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>] >>> nfsroot_to_var() { >> >> >> $ li=$(ip route show) >> $ [[ "$li" =~ "$1" ]] && echo OK >> dash: 6: [[: not found >> >> Please do not use "bash" syntax > > > For this issue, similar with the wait_for_if_up, > Probably when this scripts is called `ip route show` show nothing > because there's still no route added. In this case we should not > return 0 > > I will update the two patch like "[ -z "${li##*state UP*}" ]", > and check [ -z "$li" ] as well for the nul case Hmm, for the wait_for_if_up, pass an unexisted nic is a rare case, So I only resent the v2 patch of wait_for_route_ok. Harald, could you apply the 1/3 and the v2 of 3/3? > >> -- >> To unsubscribe from this list: send the line "unsubscribe initramfs" in >> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > -- Thanks Dave ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-16 1:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15 6:40 [PATCH 3/3] add function wait_for_route_ok Dave Young
[not found] ` <20120215064029.GA30112-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2012-02-15 8:23 ` Harald Hoyer
[not found] ` <4F3B6B9F.3070203-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-02-16 1:15 ` Dave Young
[not found] ` <4F3C58C3.6020103-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-02-16 1:39 ` Dave Young
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox