Blame 0002-add-function-wait_for_route_ok.patch

Harald Hoyer 035915
From 75cade1216b62957efad7e97c77e4e8b0414a515 Mon Sep 17 00:00:00 2001
Harald Hoyer 035915
From: Dave Young <dyoung@redhat.com>
Harald Hoyer 035915
Date: Thu, 16 Feb 2012 09:36:29 +0800
Harald Hoyer 035915
Subject: [PATCH] add function wait_for_route_ok
Harald Hoyer 035915
Harald Hoyer 035915
Manually setuping nic through udev is not always done when
Harald Hoyer 035915
we want network access. Here add a function wait_for_route_ok to
Harald Hoyer 035915
wait and make sure the network is accesible
Harald Hoyer 035915
Harald Hoyer 035915
[v1 -> v2]:
Harald Hoyer 035915
Harald: don't use bash syntax
Harald Hoyer 035915
Add check for [ -n "$li" ] because `ip route show` will show nothing probably
Harald Hoyer 035915
Harald Hoyer 035915
Signed-off-by: Dave Young <dyoung@redhat.com>
Harald Hoyer 035915
---
Harald Hoyer 035915
 modules.d/99base/dracut-lib.sh |   11 +++++++++++
Harald Hoyer 035915
 1 files changed, 11 insertions(+), 0 deletions(-)
Harald Hoyer 035915
Harald Hoyer 035915
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 035915
index 6b70adf..afd366e 100755
Harald Hoyer 035915
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 035915
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 035915
@@ -392,6 +392,17 @@ wait_for_if_up() {
Harald Hoyer 035915
     return 1
Harald Hoyer 035915
 }
Harald Hoyer 035915
 
Harald Hoyer 035915
+wait_for_route_ok() {
Harald Hoyer 035915
+    local cnt=0
Harald Hoyer 035915
+    while [ $cnt -lt 200 ]; do
Harald Hoyer 035915
+        li=$(ip route show)
Harald Hoyer 035915
+        [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
Harald Hoyer 035915
+        sleep 0.1
Harald Hoyer 035915
+        cnt=$(($cnt+1))
Harald Hoyer 035915
+    done
Harald Hoyer 035915
+    return 1
Harald Hoyer 035915
+}
Harald Hoyer 035915
+
Harald Hoyer 035915
 # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
Harald Hoyer 035915
 # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
Harald Hoyer 035915
 nfsroot_to_var() {