On 02/15/15 at 03:45pm, Minfei Huang wrote:
Add a new function to simplify to get the ip address, if the
specified
address is a domain/hostname in /etc/kdump.conf.
The function will parse the passed parameter, and use the "getent ahost"
to get the ip address, if passed parameter is domain/hostname.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 1 +
kdump-lib.sh | 27 ++++++++++++++++++---------
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index d09b339..0b5b66e 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -621,6 +621,7 @@ install() {
inst "/bin/dd" "/bin/dd"
inst "/bin/tail" "/bin/tail"
inst "/bin/date" "/bin/date"
+ inst "/bin/getent" "/bin/getent"
inst "/bin/sync" "/bin/sync"
inst "/bin/cut" "/bin/cut"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index b886c5d..624563f 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -170,21 +170,30 @@ get_remote_host()
echo $_config_val
}
+# wrap a function, so that we can use this function to get the ip address,
+# if pass a parameter
+get_ip_address()
+{
+ local _ip_address
+
+ _ip_address=`getent ahosts $1 | head -n 1 | cut -d' ' -f1`
+ _ip_address=${_ip_address:-$1}
+ echo $_ip_address
+}
+
# check the remote server ip address tpye
is_ipv6_target()
Could it be get_network_target, then call is_ipv6_address which is
implemented later? It's a little uncomfortable with ipv6_target and
ipv6_address. Kind of duplicate implementation.
{
- local _server _server_tmp
+ local _target
if is_ssh_dump_target; then
- _server=`get_option_value ssh`
+ _target=`get_option_value ssh`
elif is_nfs_dump_target; then
- _server=`get_option_value nfs`
+ _target=`get_option_value nfs`
fi
- [ -z "$_server" ] && return 1
- _server=`get_remote_host $_server`
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server | grep -q ":"
+ [ -z "$_target" ] && return 1
+ _target=`get_remote_host $_target`
+
+ echo $(get_ip_address $_target) | grep -q ":"
}
--
2.2.2