Added ie and us support. Cleaned up awk and cut commands not being called from variables.
authorChris Jones <chris@sysadminchris.com>
Mon, 14 Jan 2013 17:18:11 -0500
changeset 21 14a903cf9505
parent 20 fe1c8b4725f7
child 22 4bccc75a8a1c
Added ie and us support. Cleaned up awk and cut commands not being called from variables.
scripts/domain-check
--- a/scripts/domain-check	Tue Oct 16 15:19:02 2012 +0200
+++ b/scripts/domain-check	Mon Jan 14 17:18:11 2013 -0500
@@ -5,9 +5,13 @@
 #
 # Author: Matty < matty91 at gmail dot com >
 # 
-# Current Version: 1.9
+# Current Version: 1.95
 #
 # Revision History:
+#  Version 1.95
+#    Added support for .ie and .us domain names
+#    Cleaned up some areas where awk and cut were being called
+#    directly rather than from the variables they were asigned to. -- Chris Jones <chris@sysadminchris.com>
 #  Version 1.9
 #    Bug fix and enhancement for .uk and .co.uk -- Vivek Gite <vivek@nixcraft.com>
 #
@@ -224,10 +228,10 @@
     sleep 3
     # Save the domain since set will trip up the ordering
     DOMAIN=${1}
-    TLDTYPE="`echo ${DOMAIN} | cut -d '.' -f3 | tr '[A-Z]' '[a-z]'`" 
+    TLDTYPE="`echo ${DOMAIN} | ${CUT} -d '.' -f3 | tr '[A-Z]' '[a-z]'`" 
     if [ "${TLDTYPE}"  == "" ];
     then
-	    TLDTYPE="`echo ${DOMAIN} | cut -d '.' -f2 | tr '[A-Z]' '[a-z]'`" 
+	    TLDTYPE="`echo ${DOMAIN} | ${CUT} -d '.' -f2 | tr '[A-Z]' '[a-z]'`" 
     fi
 
     # Invoke whois to find the domain registrar and expiration date
@@ -246,12 +250,18 @@
     elif [ "${TLDTYPE}"  == "biz" ];
     then
         ${WHOIS} -h "whois.neulevel.biz" "${1}" > ${WHOIS_TMP}
+    elif [ "${TLDTYPE}"  == "ie" ]; # Ireland
+    then
+        ${WHOIS} -h "whois.domainregistry.ie" "${1}" > ${WHOIS_TMP}
     elif [ "${TLDTYPE}"  == "info" ];
     then
         ${WHOIS} -h "whois.afilias.info" "${1}" > ${WHOIS_TMP}
     elif [ "${TLDTYPE}"  == "jp" ]; # Japan
     then
         ${WHOIS} -h "whois.jprs.jp" "${1}" > ${WHOIS_TMP}
+    elif [ "${TLDTYPE}"  == "us" ];
+    then
+        ${WHOIS} -h "whois.nic.us" "${1}" > ${WHOIS_TMP}
 
     elif [ "${TLDTYPE}"  == "com" -o "${TLDTYPE}"  == "net" -o "${TLDTYPE}"  == "edu" ];
     then
@@ -272,6 +282,12 @@
     elif [ "${TLDTYPE}" == "cz" ];
     then
         REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/registrar:/ && $2 != ""  { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }'`
+    elif [ "${TLDTYPE}" == "ie" ]; # for .ie domain
+    then
+        REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/source/ && $2 != ""  { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }'`
+    elif [ "${TLDTYPE}" == "us" ];
+    then
+        REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: '/Last Updated by Registrar:/ && $2 != ""  { REGISTRAR=substr($2,20,17) } END { print REGISTRAR }'`
     fi
 
     # If the Registrar is NULL, then we didn't get any data
@@ -286,18 +302,43 @@
     # for .in, .info, .org domains
     if [ "${TLDTYPE}" == "in" -o "${TLDTYPE}" == "info" -o "${TLDTYPE}" == "org" ];
     then
-	    DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Expiration Date:/ { print $2 }' | cut -d':' -f2`
+	    DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Expiration Date:/ { print $2 }' | ${CUT} -d':' -f2`
     elif [ "${TLDTYPE}" == "biz" ]; # for .biz domain
     then
-            DOMAINDATE=`cat ${WHOIS_TMP} | awk '/Domain Expiration Date:/ { print $6"-"$5"-"$9 }'`
+            DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Domain Expiration Date:/ { print $6"-"$5"-"$9 }'`
+    elif [ "${TLDTYPE}" == "ie" ]; # for .ie domain
+    then
+            tdomdate=`cat ${WHOIS_TMP} | ${AWK} '/renewal/ { print $2 }'`
+            tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3`
+            tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
+	       case ${tmon} in
+	             "January") tmonth=jan ;;
+	             "February") tmonth=feb ;;
+	             "March") tmonth=mar ;;
+	             "April") tmonth=apr ;;
+	             "May") tmonth=may ;;
+	             "June") tmonth=jun ;;
+	             "July") tmonth=jul ;;
+	             "August") tmonth=aug ;;
+	             "September") tmonth=sep ;;
+	             "October")tmonth=oct ;;
+	             "November") tmonth=nov ;;
+	             "December") tmonth=dec ;;
+               	      *) tmonth=0 ;;
+		esac
+            tday=`echo ${tdomdate} | ${CUT} -d'-' -f1`
+	    DOMAINDATE=`echo $tday-$tmonth-$tyear`
     elif [ "${TLDTYPE}" == "uk" ]; # for .uk domain
     then
-            DOMAINDATE=`cat ${WHOIS_TMP} | awk '/Renewal date:/ || /Expiry date:/ { print $3 }'`
+            DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Renewal date:/ || /Expiry date:/ { print $3 }'`
+    elif [ "${TLDTYPE}" == "us" ]; # for .us domain
+    then
+            DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Domain Expiration Date:/ { print $6"-"$5"-"$9 }'`
     elif [ "${TLDTYPE}" == "jp" ]; # for .jp 2010/04/30
     then
-	    tdomdate=`cat ${WHOIS_TMP} | awk '/Expires on/ { print $3 }'`
-            tyear=`echo ${tdomdate} | cut -d'/' -f1`
-            tmon=`echo ${tdomdate} | cut -d'/' -f2`
+	    tdomdate=`cat ${WHOIS_TMP} | ${AWK} '/Expires on/ { print $3 }'`
+            tyear=`echo ${tdomdate} | ${CUT} -d'/' -f1`
+            tmon=`echo ${tdomdate} | ${CUT} -d'/' -f2`
 	       case ${tmon} in
 	             1|01) tmonth=jan ;;
 	             2|02) tmonth=feb ;;
@@ -313,7 +354,7 @@
 	             12) tmonth=dec ;;
                	      *) tmonth=0 ;;
 		esac
-            tday=`echo ${tdomdate} | cut -d'/' -f3`
+            tday=`echo ${tdomdate} | ${CUT} -d'/' -f3`
 	    DOMAINDATE=`echo $tday-$tmonth-$tyear`
     elif [ "${TLDTYPE}" == "cz" ]; # for .cz 08.02.2013 dd.mm.yyyy
     then