#!/usr/bin/env bash

# - Test if given argument is a valid IPv6 Address
# -
is_valid_ipv6() {
   local _ipv6="$1"

   _regex_ipv6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'


   if [[ "$_ipv6" =~ ${_regex_ipv6} ]]; then
      return 0
   else
      return 1
   fi
}

if [ "X$@" = "X" ]; then
   echo -e "\n\t\033[33m\033[1mNo argumnet given!\033[m\n"
   exit 1
fi

if is_valid_ipv6 $@ ; then
   echo -e "\n\t\033[32m\033[1m$@ is a valid IPv6 Address\033[m\n"
else
   echo -e "\n\t\033[31m\033[1m$@ is NOT a valid IPv6 Address\033[m\n"
fi

exit

