The ipv6 address has the special character colon ":", so we can use the
new function to pick it out.
We can use the new function to parse the passed parameter. The passed
parameter is hostname/domain, if it is satisfied with the condition that
it is without colon ":", and contanis the [a-zA-Z].
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
kdump-lib.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 624563f..5f4caa3 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -181,6 +181,15 @@ get_ip_address()
echo $_ip_address
}
+# the ipv6 address has the special character colon ":", so we can pick it out.
+# we can pass a ip address, if ipv6 address, will return ipv6 address,
+# otherwise return NULL
+is_ipv6_address()
+{
+ local _server=$(get_ip_address $1)
+ echo $_server | grep -q ":"
+}
+
# check the remote server ip address tpye
is_ipv6_target()
{
@@ -197,3 +206,17 @@ is_ipv6_target()
echo $(get_ip_address $_target) | grep -q ":"
}
+
+# if the passed parameter is hostname/domain, it will be satisfied with
+# condition which it is without colon ":", and contains the [a-zA-Z]
+is_hostname()
+{
+ local _hostname=`echo $1 | grep ":"`
+
+# ipv6 address
+ if [ -n "$_hostname" ]; then
+ return 1
+ else
+ echo $1 | grep -q "[a-zA-Z]"
+ fi
+}
--
2.2.2