#!/bin/bash #set -x print_usage() { printf "Usage: aliastest.sh -a alis-domain.tld -d domain.tld domain2.tld" } # Get the options while getopts ":h:a:d:" option; do case $option in h) # display Help print_usage exit;; a) # The alias hostname for check hostname=$OPTARG ;; d) # Domain or domains domains=$OPTARG ;; esac done for domain in $domains do echo "Check for $domain:" echo "-------------------" CNAME=$(dig +short CNAME $domain) if [ "${CNAME}" == "${hostname}." ]; then echo "$domain is alias for $hostname" else echo "$domain is NOT alias for $hostname" fi done
Views: 55