From efa5eb424dcf5a64fa6365850a07e4068a6b4309 Mon Sep 17 00:00:00 2001 From: "dyoung@redhat.com" Date: Wed, 12 Dec 2012 12:23:21 +0800 Subject: [PATCH] Move wait for if functions to net lib net-lib.sh are created for net related functions, move the wait_for_if* to net-lib.sh naturally. Signed-off-by: Dave Young --- modules.d/40network/dhclient-script.sh | 1 + modules.d/40network/net-lib.sh | 23 +++++++++++++++++++++++ modules.d/95fcoe/fcoe-up.sh | 1 + modules.d/99base/dracut-lib.sh | 23 ----------------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh index 1500fe51..12a67e8b 100755 --- a/modules.d/40network/dhclient-script.sh +++ b/modules.d/40network/dhclient-script.sh @@ -51,6 +51,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin export PS4="dhclient.$interface.$$ + " exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh +type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh # We already need a set netif here netif=$interface diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 9b2f2918..8bab2b60 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -322,3 +322,26 @@ parse_ifname_opts() { esac } + +wait_for_if_up() { + local cnt=0 + local li + while [ $cnt -lt 200 ]; do + li=$(ip -o link show up dev $1) + [ -n "$li" ] && return 0 + sleep 0.1 + cnt=$(($cnt+1)) + done + return 1 +} + +wait_for_route_ok() { + local cnt=0 + while [ $cnt -lt 200 ]; do + li=$(ip route show) + [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 + sleep 0.1 + cnt=$(($cnt+1)) + done + return 1 +} diff --git a/modules.d/95fcoe/fcoe-up.sh b/modules.d/95fcoe/fcoe-up.sh index d808dd5f..85468ef9 100755 --- a/modules.d/95fcoe/fcoe-up.sh +++ b/modules.d/95fcoe/fcoe-up.sh @@ -16,6 +16,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin export PS4="fcoe-up.$1.$$ + " exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh +type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh netif=$1 dcb=$2 diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index cc6c7e81..127ae429 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -481,29 +481,6 @@ else } fi -wait_for_if_up() { - local cnt=0 - local li - while [ $cnt -lt 200 ]; do - li=$(ip -o link show up dev $1) - [ -n "$li" ] && return 0 - sleep 0.1 - cnt=$(($cnt+1)) - done - return 1 -} - -wait_for_route_ok() { - local cnt=0 - while [ $cnt -lt 200 ]; do - li=$(ip route show) - [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 - sleep 0.1 - cnt=$(($cnt+1)) - done - return 1 -} - # root=nfs:[:][:] # root=nfs4:[:][:] nfsroot_to_var() {