From edec8a826634cdec878984b61659d9b60efbd578 Mon Sep 17 00:00:00 2001 From: Minfei Huang Date: Thu, 23 Jul 2015 18:29:23 +0800 Subject: [PATCH] dracut-kdump: Use the first filtered ip address as dump directory For now, Kdump will use ipv4 address as dump directory, and it works, if ipv4 is enabled. Once Kdump start to support ipv6 protocol, we may only setup the ipv6 address exclusively. Modify the code to make Kdump work in either ipv4 and ipv6 protocol. Signed-off-by: Minfei Huang Acked-by: Dave Young --- dracut-kdump.sh | 4 ++-- dracut-module-setup.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index dc948d1..4aab205 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -121,9 +121,9 @@ get_host_ip() then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 - _host=`ip addr show dev $kdumpnic|grep 'inet '` + _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - _host="${_host##*inet }" + _host=`echo $_host | head -n 1 | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b4f3413..625b9ee 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -658,6 +658,7 @@ install() { inst "/bin/date" "/bin/date" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" + inst "/bin/head" "/bin/head" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"