Add a new lib to check whether the parameter is ipv4 or ipv6. Return true, if the parameter is ipv6, otherwise return false.
Add a new lib to check whether the parameter is hostname/domain. Return turn, if the parameter is hostname/domain, otherwise return false.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 6ca2b3a..cb1bab7 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -179,6 +179,12 @@ get_ip_address() echo $_ip_address }
+is_ipv6_address() +{ + local _server=$(get_ip_address $1) + echo $_server | grep -q ":" +} + # check the remote server ip address tpye is_ipv6_target() { @@ -195,3 +201,17 @@ is_ipv6_target()
echo $(get_ip_address $_target) | grep -q ":" } + +is_hostname() +{ + local _hostname=`echo $1 | grep ":"` + +# ipv6 address + if [ -n "$_hostname" ]; then + return 1 + else +# if contains the character, it is hostname, +# otherwise is ipv4 address + echo $1 | grep -q "[a-zA-Z]" + fi +}