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