Advertisement
StraNNicK

Check domains for expired

Sep 26th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.14 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Program: Domain Expiration Check <domain-check>
  4. #
  5. # Author: Matty < matty91 at gmail dot com >
  6. #
  7. # Current Version: 2.0
  8. #
  9. # Revision History:
  10. #  Version 2.0
  11. #  Added support for .ru, .рф and .ua domain names -- Eugene Chaykin <strannick@gmail.com>
  12. #  Added workaround for printf (troubles with IDN)
  13. #
  14. #  Version 1.9
  15. #    Bug fix and enhancement for .uk and .co.uk -- Vivek Gite <vivek@nixcraft.com>
  16. #
  17. #  Version 1.8
  18. #    Bug fix added $MAIL -- Vivek Gite <vivek@nixcraft.com>
  19. #
  20. #  Version 1.7
  21. #    Added support for .jp domain names  -- Vivek Gite <vivek@nixcraft.com>
  22. #
  23. #  Version 1.6
  24. #    Added support for .uk domain names; fixed a bug detecting tldtype  -- Vivek Gite <vivek@nixcraft.com>
  25. #
  26. #  Version 1.5
  27. #    Added support for .org, .in, .biz and .info domain names -- Vivek Gite <vivek@nixcraft.com>
  28. #
  29. #  Version 1.4
  30. #    Updated the documentation.
  31. #
  32. #  Version 1.3
  33. #    Gracefully Handle the case where the expiration data is unavailable
  34. #
  35. #  Version 1.2
  36. #    Added "-s" option to allow arbitrary registrars
  37. #
  38. #  Version 1.1
  39. #    Fixed issue with 'e' getopt string -- Pedro Alves
  40. #
  41. #  Version 1.0
  42. #    Initial Release
  43. #
  44. # Last Updated: 07-Aug-2012
  45. #
  46. # Purpose:
  47. #  domain-check checks to see if a domain has expired. domain-check
  48. #  can be run in interactive and batch mode, and provides faciltities
  49. #  to alarm if a domain is about to expire.
  50. #
  51. # License:
  52. #  This program is distributed in the hope that it will be useful,
  53. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  54. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  55. #
  56. # Notes:
  57. #   Since each registrar provides expiration data in a unique format (if
  58. #   they provide it at all), domain-check is currently only able to
  59. #   processess expiration information for a subset of the available
  60. #   registrars.
  61. #
  62. # Requirements:
  63. #   Requires whois
  64. #
  65. # Installation:
  66. #   Copy the shell script to a suitable location
  67. #
  68. # Tested platforms:
  69. #  -- Solaris 9 using /bin/bash
  70. #  -- Solaris 10 using /bin/bash
  71. #  -- OS X 10.4.2 using /bin/sh
  72. #  -- OpenBSD using /bin/sh
  73. #  -- FreeBSD using /bin/sh
  74. #  -- Redhat advanced server 3.0MU3 using /bin/sh
  75. #
  76. # Usage:
  77. #  Refer to the usage() sub-routine, or invoke domain-check
  78. #  with the "-h" option.
  79. #
  80. # Example:
  81. #
  82. #  The first example will print the expiration date and registrar for prefetch.net:
  83. #
  84. #  $ domain-check.sh -d prefetch.net
  85. #
  86. #  Domain                              Registrar         Status   Expires     Days Left
  87. #  ----------------------------------- ----------------- -------- ----------- ---------
  88. #  prefetch.net                        INTERCOSMOS MEDIA Valid    13-feb-2006   64
  89. #
  90. #  The second example prints the expiration date and registrar for the domains
  91. #  listed in the file "domains":
  92. #
  93. #  $ domain-check.sh -f domains
  94. #
  95. #  Domain                              Registrar         Status   Expires     Days Left
  96. #  ----------------------------------- ----------------- -------- ----------- ---------
  97. #  sun.com                             NETWORK SOLUTIONS Valid    20-mar-2010   1560
  98. #  google.com                          EMARKMONITOR INC. Valid    14-sep-2011   2103
  99. #  ack.com                             NETWORK SOLUTIONS Valid    09-may-2008   880
  100. #  prefetch.net                        INTERCOSMOS MEDIA Valid    13-feb-2006   64
  101. #  spotch.com                          GANDI             Valid    03-dec-2006   357
  102. #
  103. #  The third example will e-mail the address admin@prefetch.net with the domains that
  104. #  will expire in 60-days or less:
  105. #
  106. #  $ domain-check -a -f domains -q -x 60 -e admin@prefetch.net
  107. #
  108.  
  109. PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/ssl/bin:/usr/sfw/bin ; export PATH
  110.  
  111. # Who to page when an expired domain is detected (cmdline: -e)
  112. ADMIN="admin@nanocad.ru"
  113.  
  114. # Number of days in the warning threshhold  (cmdline: -x)
  115. WARNDAYS=30
  116.  
  117. # If QUIET is set to TRUE, don't print anything on the console (cmdline: -q)
  118. QUIET="FALSE"
  119.  
  120. # Don't send emails by default (cmdline: -a)
  121. ALARM="FALSE"
  122.  
  123. # Whois server to use (cmdline: -s)
  124. WHOIS_SERVER="whois.internic.org"
  125.  
  126. # Location of system binaries
  127. AWK="/usr/bin/awk"
  128. WHOIS="/usr/bin/whois"
  129. DATE="/bin/date"
  130. CUT="/usr/bin/cut"
  131. MAIL="/usr/bin/mail"
  132. # Place to stash temporary files
  133. WHOIS_TMP="/var/tmp/whois.$$"
  134.  
  135. function formatwidth
  136. {
  137.   local STR=$1; shift
  138.   local WIDTH=$1; shift
  139.   local BYTEWIDTH=$( echo -n "$STR" | wc -c )
  140.   local CHARWIDTH=$( echo -n "$STR" | wc -m )
  141.   echo $(( $WIDTH + $BYTEWIDTH - $CHARWIDTH ))
  142. }
  143.  
  144. #############################################################################
  145. # Purpose: Convert a date from MONTH-DAY-YEAR to Julian format
  146. # Acknowledgements: Code was adapted from examples in the book
  147. #                   "Shell Scripting Recipes: A Problem-Solution Approach"
  148. #                   ( ISBN 1590594711 )
  149. # Arguments:
  150. #   $1 -> Month (e.g., 06)
  151. #   $2 -> Day   (e.g., 08)
  152. #   $3 -> Year  (e.g., 2006)
  153. #############################################################################
  154. date2julian()
  155. {
  156.     if [ "${1} != "" ] && [ "${2} != ""  ] && [ "${3}" != "" ]
  157.     then
  158.          ## Since leap years add aday at the end of February,
  159.          ## calculations are done from 1 March 0000 (a fictional year)
  160.          d2j_tmpmonth=$((12 * ${3} + ${1} - 3))
  161.  
  162.           ## If it is not yet March, the year is changed to the previous year
  163.           d2j_tmpyear=$(( ${d2j_tmpmonth} / 12))
  164.  
  165.           ## The number of days from 1 March 0000 is calculated
  166.           ## and the number of days from 1 Jan. 4713BC is added
  167.           echo $(( (734 * ${d2j_tmpmonth} + 15) / 24 -  2 * ${d2j_tmpyear} + ${d2j_tmpyear}/4
  168.                         - ${d2j_tmpyear}/100 + ${d2j_tmpyear}/400 + $2 + 1721119 ))
  169.     else
  170.           echo 0
  171.     fi
  172. }
  173.  
  174. #############################################################################
  175. # Purpose: Convert a string month into an integer representation
  176. # Arguments:
  177. #   $1 -> Month name (e.g., Sep)
  178. #############################################################################
  179. getmonth()
  180. {
  181.        LOWER=`tolower $1`
  182.  
  183.        case ${LOWER} in
  184.              jan) echo 1 ;;
  185.              feb) echo 2 ;;
  186.              mar) echo 3 ;;
  187.              apr) echo 4 ;;
  188.              may) echo 5 ;;
  189.              jun) echo 6 ;;
  190.              jul) echo 7 ;;
  191.              aug) echo 8 ;;
  192.              sep) echo 9 ;;
  193.              oct) echo 10 ;;
  194.              nov) echo 11 ;;
  195.              dec) echo 12 ;;
  196.                *) echo  0 ;;
  197.        esac
  198. }
  199.  
  200. #############################################################################
  201. # Purpose: Calculate the number of seconds between two dates
  202. # Arguments:
  203. #   $1 -> Date #1
  204. #   $2 -> Date #2
  205. #############################################################################
  206. date_diff()
  207. {
  208.         if [ "${1}" != "" ] &&  [ "${2}" != "" ]
  209.         then
  210.                 echo $(expr ${2} - ${1})
  211.         else
  212.                 echo 0
  213.         fi
  214. }
  215.  
  216. ##################################################################
  217. # Purpose: Converts a string to lower case
  218. # Arguments:
  219. #   $1 -> String to convert to lower case
  220. ##################################################################
  221. tolower()
  222. {
  223.      LOWER=`echo ${1} | tr [A-Z] [a-z]`
  224.      echo $LOWER
  225. }
  226.  
  227. ##################################################################
  228. # Purpose: Access whois data to grab the registrar and expiration date
  229. # Arguments:
  230. #   $1 -> Domain to check
  231. ##################################################################
  232. check_domain_status()
  233. {
  234.     local REGISTRAR=""
  235.     # Avoid WHOIS LIMIT EXCEEDED - slowdown our whois client by adding 3 sec
  236.     sleep 3
  237.     # Save the domain since set will trip up the ordering
  238.     DOMAIN=${1}
  239.     TLDTYPE="`echo ${DOMAIN} | cut -d '.' -f3 | tr '[A-Z]' '[a-z]'`"
  240.     if [ "${TLDTYPE}"  == "" ];
  241.     then
  242.         TLDTYPE="`echo ${DOMAIN} | cut -d '.' -f2 | tr '[A-Z]' '[a-z]'`"
  243.     fi
  244.  
  245.     # Invoke whois to find the domain registrar and expiration date
  246.     #${WHOIS} -h ${WHOIS_SERVER} "=${1}" > ${WHOIS_TMP}
  247.     # Let whois select server
  248.     if [ "${TLDTYPE}"  == "org" ];
  249.     then
  250.         ${WHOIS} -h "whois.pir.org" "${1}" > ${WHOIS_TMP}
  251.     elif [ "${TLDTYPE}"  == "in" ]; # India
  252.     then
  253.         ${WHOIS} -h "whois.registry.in" "${1}" > ${WHOIS_TMP}
  254.     elif [ "${TLDTYPE}"  == "uk" ]; # United Kingdom
  255.     then
  256.         ${WHOIS} -h "whois.nic.uk" "${1}" > ${WHOIS_TMP}
  257.  
  258.     elif [ "${TLDTYPE}"  == "biz" ];
  259.     then
  260.         ${WHOIS} -h "whois.neulevel.biz" "${1}" > ${WHOIS_TMP}
  261.     elif [ "${TLDTYPE}"  == "info" ];
  262.     then
  263.         ${WHOIS} -h "whois.afilias.info" "${1}" > ${WHOIS_TMP}
  264.     elif [ "${TLDTYPE}"  == "jp" ]; # Japan
  265.     then
  266.         ${WHOIS} -h "whois.jprs.jp" "${1}" > ${WHOIS_TMP}
  267.     elif [ "${TLDTYPE}" == "ru" ]; # Russia
  268.     then
  269.         ${WHOIS} -h "whois.nic.ru" "${1}" > ${WHOIS_TMP}
  270.     elif [ "${TLDTYPE}" == "xn--p1ai" -o "${TLDTYPE}" == "СЂС„" ]; # Russia IDN
  271.     then
  272.         ${WHOIS} -h "whois.tcinet.ru" "${1}" > ${WHOIS_TMP}
  273.     elif [ "${TLDTYPE}" == "ua" ]; # Ukraine
  274.     then
  275.         ${WHOIS} -h "whois.ua" "${1}" > ${WHOIS_TMP}
  276.  
  277.     elif [ "${TLDTYPE}"  == "com" -o "${TLDTYPE}"  == "net" -o "${TLDTYPE}"  == "edu" ];
  278.     then
  279.     ${WHOIS} -h ${WHOIS_SERVER} "=${1}" > ${WHOIS_TMP}
  280.     else
  281.     ${WHOIS} "${1}" > ${WHOIS_TMP}
  282.     fi
  283.  
  284.     # Parse out the expiration date and registrar -- uses the last registrar it finds
  285.     REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: '/Registrar/ && $2 != ""  { REGISTRAR=substr($2,2,17) } END { print REGISTRAR }'`
  286.  
  287.     if [ "${TLDTYPE}" == "uk" ]; # for .uk domain
  288.     then
  289.     REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} -F: '/Registrar:/ && $0 != ""  { getline; REGISTRAR=substr($0,2,17) } END { print REGISTRAR }'`
  290.     elif [ "${TLDTYPE}" == "jp" ];
  291.     then
  292.         REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/Registrant/ && $2 != ""  { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }'`
  293.     elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "xn--p1ai" -o "${TLDTYPE}" == "СЂС„" ];
  294.     then
  295.         REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/registrar/ && $2 != ""  { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }'`
  296.     elif [ "${TLDTYPE}" == "ua" ];
  297.     then
  298.         REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/source/ && $2 != ""  { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }'`
  299.     elif [ "${TLDTYPE}" == "info" ];
  300.     then
  301.         REGISTRAR=`cat ${WHOIS_TMP} | ${AWK} '/Registrar/  && $9 != "" { REGISTRAR=substr($9,2,9) } END { print REGISTRAR }'`
  302.     fi
  303.  
  304.     # If the Registrar is NULL, then we didn't get any data
  305.     if [ "${REGISTRAR}" = "" ]
  306.     then
  307.         prints "$DOMAIN" "Unknown" "Unknown" "Unknown" "Unknown"
  308.         return
  309.     fi
  310.  
  311.     # The whois Expiration data should resemble the following: "Expiration Date: 09-may-2008"
  312.  
  313.     # for .in, .info, .org domains
  314.     if [ "${TLDTYPE}" == "in" -o "${TLDTYPE}" == "info" -o "${TLDTYPE}" == "org" ];
  315.     then
  316.         DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Expiration Date:/ { print $2 }' | cut -d':' -f2`
  317.     elif [ "${TLDTYPE}" == "biz" ]; # for .biz domain
  318.     then
  319.             DOMAINDATE=`cat ${WHOIS_TMP} | awk '/Domain Expiration Date:/ { print $6"-"$5"-"$9 }'`
  320.     elif [ "${TLDTYPE}" == "uk" ]; # for .uk domain
  321.     then
  322.             DOMAINDATE=`cat ${WHOIS_TMP} | awk '/Renewal date:/ || /Expiry date:/ { print $3 }'`
  323.     elif [ "${TLDTYPE}" == "jp" ]; # for .jp 2010/04/30
  324.     then
  325.         tdomdate=`cat ${WHOIS_TMP} | awk '/Expires on/ { print $3 }'`
  326.             tyear=`echo ${tdomdate} | cut -d'/' -f1`
  327.             tmon=`echo ${tdomdate} | cut -d'/' -f2`
  328.            case ${tmon} in
  329.                  1|01) tmonth=jan ;;
  330.                  2|02) tmonth=feb ;;
  331.                  3|03) tmonth=mar ;;
  332.                  4|04) tmonth=apr ;;
  333.                  5|05) tmonth=may ;;
  334.                  6|06) tmonth=jun ;;
  335.                  7|07) tmonth=jul ;;
  336.                  8|08) tmonth=aug ;;
  337.                  9|09) tmonth=sep ;;
  338.                  10)tmonth=oct ;;
  339.                  11) tmonth=nov ;;
  340.                  12) tmonth=dec ;;
  341.                       *) tmonth=0 ;;
  342.         esac
  343.             tday=`echo ${tdomdate} | cut -d'/' -f3`
  344.         DOMAINDATE=`echo $tday-$tmonth-$tyear`
  345.     elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "СЂС„" -o "${TLDTYPE}" == "XN--P1AI" ]; # for .ru 2010.04.30
  346.     then
  347.             tdomdate=`cat ${WHOIS_TMP} | awk '/paid-till/ { print $2 }'`
  348.             tyear=`echo ${tdomdate} | cut -d'.' -f1`
  349.             tmon=`echo ${tdomdate} | cut -d'.' -f2`
  350.                case ${tmon} in
  351.                      1|01) tmonth=jan ;;
  352.                      2|02) tmonth=feb ;;
  353.                      3|03) tmonth=mar ;;
  354.                      4|04) tmonth=apr ;;
  355.                      5|05) tmonth=may ;;
  356.                      6|06) tmonth=jun ;;
  357.                      7|07) tmonth=jul ;;
  358.                      8|08) tmonth=aug ;;
  359.                      9|09) tmonth=sep ;;
  360.                      10)tmonth=oct ;;
  361.                      11) tmonth=nov ;;
  362.                      12) tmonth=dec ;;
  363.                       *) tmonth=0 ;;
  364.                 esac
  365.             tday=`echo ${tdomdate} | cut -d'.' -f3`
  366.             DOMAINDATE=`echo $tday-$tmonth-$tyear`
  367.     elif [ "${TLDTYPE}" == "ua" ];
  368.     then
  369.             tdomdate=`cat ${WHOIS_TMP} | awk '/status/ && $3 != ""  { DATE=substr($3,1,8) } END { print DATE }'`
  370.             tyear=`echo ${tdomdate} | cut -c1-4`
  371.             tmon=`echo ${tdomdate} | cut -c5-6`
  372.                case ${tmon} in
  373.                      1|01) tmonth=jan ;;
  374.                      2|02) tmonth=feb ;;
  375.                      3|03) tmonth=mar ;;
  376.                      4|04) tmonth=apr ;;
  377.                      5|05) tmonth=may ;;
  378.                      6|06) tmonth=jun ;;
  379.                      7|07) tmonth=jul ;;
  380.                      8|08) tmonth=aug ;;
  381.                      9|09) tmonth=sep ;;
  382.                      10)tmonth=oct ;;
  383.                      11) tmonth=nov ;;
  384.                      12) tmonth=dec ;;
  385.                       *) tmonth=0 ;;
  386.                 esac
  387.             tday=`echo ${tdomdate} | cut -c7-8`
  388.             DOMAINDATE=`echo $tday-$tmonth-$tyear`
  389.     else # .com, .edu, .net and may work with other
  390.         DOMAINDATE=`cat ${WHOIS_TMP} | ${AWK} '/Expiration/ { print $NF }'`
  391.     fi
  392.  
  393.     #echo $DOMAINDATE # debug
  394.     # Whois data should be in the following format: "13-feb-2006"
  395.     IFS="-"
  396.     set -- ${DOMAINDATE}
  397.     MONTH=$(getmonth ${2})
  398.     IFS=""
  399.  
  400.     # Convert the date to seconds, and get the diff between NOW and the expiration date
  401.     DOMAINJULIAN=$(date2julian ${MONTH} ${1#0} ${3})
  402.     DOMAINDIFF=$(date_diff ${NOWJULIAN} ${DOMAINJULIAN})
  403.  
  404.     if [ ${DOMAINDIFF} -lt 0 ]
  405.     then
  406.           if [ "${ALARM}" = "TRUE" ]
  407.           then
  408.                 echo "The domain ${DOMAIN} has expired!" \
  409.                 | ${MAIL} -s "Domain ${DOMAIN} has expired!" ${ADMIN}
  410.            fi
  411.  
  412.            prints ${DOMAIN} "Expired" "${DOMAINDATE}" "${DOMAINDIFF}" ${REGISTRAR}
  413.  
  414.     elif [ ${DOMAINDIFF} -lt ${WARNDAYS} ]
  415.     then
  416.            if [ "${ALARM}" = "TRUE" ]
  417.            then
  418.                     echo "The domain ${DOMAIN} will expire on ${DOMAINDATE}" \
  419.                     | ${MAIL} -s "Domain ${DOMAIN} will expire in ${WARNDAYS}-days or less" ${ADMIN}
  420.             fi
  421.             prints ${DOMAIN} "Expiring" "${DOMAINDATE}" "${DOMAINDIFF}" "${REGISTRAR}"
  422.      else
  423.             prints ${DOMAIN} "Valid" "${DOMAINDATE}"  "${DOMAINDIFF}" "${REGISTRAR}"
  424.      fi
  425. }
  426.  
  427. ####################################################
  428. # Purpose: Print a heading with the relevant columns
  429. # Arguments:
  430. #   None
  431. ####################################################
  432. print_heading()
  433. {
  434.         if [ "${QUIET}" != "TRUE" ]
  435.         then
  436.                 printf "\n%-35s %-17s %-8s %-11s %-5s\n" "Domain" "Registrar" "Status" "Expires" "Days Left"
  437.                 echo "----------------------------------- ----------------- -------- ----------- ---------"
  438.         fi
  439. }
  440.  
  441. #####################################################################
  442. # Purpose: Print a line with the expiraton interval
  443. # Arguments:
  444. #   $1 -> Domain
  445. #   $2 -> Status of domain (e.g., expired or valid)
  446. #   $3 -> Date when domain will expire
  447. #   $4 -> Days left until the domain will expire
  448. #   $5 -> Domain registrar
  449. #####################################################################
  450. prints()
  451. {
  452.     if [ "${QUIET}" != "TRUE" ]
  453.     then
  454.             MIN_DATE=$(echo $3 | ${AWK} '{ print $1, $2, $4 }')
  455.             printf "%-$( formatwidth "$1" 35 )s %-17s %-8s %-11s %-5s\n" "$1" "$5" "$2" "$MIN_DATE" "$4"
  456.     fi
  457. }
  458.  
  459. ##########################################
  460. # Purpose: Describe how the script works
  461. # Arguments:
  462. #   None
  463. ##########################################
  464. usage()
  465. {
  466.         echo "Usage: $0 [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ]"
  467.         echo "          {[ -d domain_namee ]} || { -f domainfile}"
  468.         echo ""
  469.         echo "  -a               : Send a warning message through email "
  470.         echo "  -d domain        : Domain to analyze (interactive mode)"
  471.         echo "  -e email address : Email address to send expiration notices"
  472.         echo "  -f domain file   : File with a list of domains"
  473.         echo "  -h               : Print this screen"
  474.         echo "  -s whois server  : Whois sever to query for information"
  475.         echo "  -q               : Don't print anything on the console"
  476.         echo "  -x days          : Domain expiration interval (eg. if domain_date < days)"
  477.         echo ""
  478. }
  479.  
  480. ### Evaluate the options passed on the command line
  481. while getopts ae:f:hd:s:qx: option
  482. do
  483.         case "${option}"
  484.         in
  485.                 a) ALARM="TRUE";;
  486.                 e) ADMIN=${OPTARG};;
  487.                 d) DOMAIN=${OPTARG};;
  488.                 f) SERVERFILE=$OPTARG;;
  489.                 s) WHOIS_SERVER=$OPTARG;;
  490.                 q) QUIET="TRUE";;
  491.                 x) WARNDAYS=$OPTARG;;
  492.                 \?) usage
  493.                     exit 1;;
  494.         esac
  495. done
  496.  
  497. ### Check to see if the whois binary exists
  498. if [ ! -f ${WHOIS} ]
  499. then
  500.         echo "ERROR: The whois binary does not exist in ${WHOIS} ."
  501.         echo "  FIX: Please modify the \$WHOIS variable in the program header."
  502.         exit 1
  503. fi
  504.  
  505. ### Check to make sure a date utility is available
  506. if [ ! -f ${DATE} ]
  507. then
  508.         echo "ERROR: The date binary does not exist in ${DATE} ."
  509.         echo "  FIX: Please modify the \$DATE variable in the program header."
  510.         exit 1
  511. fi
  512.  
  513. ### Baseline the dates so we have something to compare to
  514. MONTH=$(${DATE} "+%m")
  515. DAY=$(${DATE} "+%d")
  516. YEAR=$(${DATE} "+%Y")
  517. NOWJULIAN=$(date2julian ${MONTH#0} ${DAY#0} ${YEAR})
  518.  
  519. ### Touch the files prior to using them
  520. touch ${WHOIS_TMP}
  521.  
  522. ### If a HOST and PORT were passed on the cmdline, use those values
  523. if [ "${DOMAIN}" != "" ]
  524. then
  525.         print_heading
  526.         check_domain_status "${DOMAIN}"
  527. ### If a file and a "-a" are passed on the command line, check all
  528. ### of the domains in the file to see if they are about to expire
  529. elif [ -f "${SERVERFILE}" ]
  530. then
  531.         print_heading
  532.         while read DOMAIN
  533.         do
  534.                 check_domain_status "${DOMAIN}"
  535.  
  536.         done < ${SERVERFILE}
  537.  
  538. ### There was an error, so print a detailed usage message and exit
  539. else
  540.         usage
  541.         exit 1
  542. fi
  543.  
  544. # Add an extra newline
  545. echo
  546.  
  547. ### Remove the temporary files
  548. rm -f ${WHOIS_TMP}
  549.  
  550. ### Exit with a success indicator
  551. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement