Skip to content

Instantly share code, notes, and snippets.

@wei
Forked from zhovner/whois-change.sh
Last active August 4, 2017 13:26
Show Gist options
  • Select an option

  • Save wei/51c19c9bae2d4584223852010bebde5a to your computer and use it in GitHub Desktop.

Select an option

Save wei/51c19c9bae2d4584223852010bebde5a to your computer and use it in GitHub Desktop.

Revisions

  1. wei revised this gist Jul 28, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    #
    # Run this script once per minute
    #
    # * * * * * /path/to/whois-watch.sh google.com apple.com
    # * * * * * /path/to/whois-watch.sh google.com apple.com >> /var/log/whois-watch.log 2>&1
    # update username in mail command
    # update sed command depending on server return text
    #
  2. wei revised this gist Jul 28, 2017. 1 changed file with 30 additions and 21 deletions.
    51 changes: 30 additions & 21 deletions whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -3,30 +3,39 @@
    #
    # Run this script once per minute
    #
    # * * * * * /path/to/whois-watch.sh google.com
    # * * * * * /path/to/whois-watch.sh google.com apple.com
    # update username in mail command
    # update sed command depending on server return text
    #

    DOMAIN=$1
    if [ -z "$DOMAIN" ]; then
    DOMAIN=GATECH.EDU
    fi
    OLD="/tmp/$DOMAIN.old.whois.txt"
    NEW="/tmp/$DOMAIN.new.whois.txt"
    DIFF="/tmp/$DOMAIN.whois.diff.txt"
    TMP_DIR="/tmp"

    if [ ! -f $OLD ]; then
    echo "not available" > $OLD
    fi
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > $NEW
    OLDHASH=$(/sbin/md5 $OLD | awk '{print $4}')
    NEWHASH=$(/sbin/md5 $NEW | awk '{print $4}')
    function TIMESTAMP() {
    echo $(date -u +"%Y-%m-%d-%H:%M:%S")
    }
    NEWLINE=$'\n'

    if [ "$OLDHASH" != "$NEWHASH" ]; then
    echo "$DOMAIN WHOIS Updated"
    diff $NEW $OLD > $DIFF
    mail -s "Whois information of $DOMAIN changed" root < $DIFF
    rm $DIFF
    fi
    mv $NEW $OLD
    for DOMAIN in "$@"
    do
    echo "[whois-watch.sh][$(TIMESTAMP)] Checking whois for $DOMAIN"
    OLD="$TMP_DIR/$DOMAIN.old.whois.txt"
    NEW="$TMP_DIR/$DOMAIN.new.whois.txt"
    DIFF="$TMP_DIR/$DOMAIN.whois.diff.txt"

    if [ ! -f $OLD ]; then
    echo "not available" > $OLD
    fi
    whois $DOMAIN -H | sed -e 's/^.*last update.*$//gI' > $NEW
    OLDHASH=$(sha1sum $OLD | awk '{print $1}')
    NEWHASH=$(sha1sum $NEW | awk '{print $1}')

    if [ "$OLDHASH" != "$NEWHASH" ]; then
    echo "[whois-watch.sh][$(TIMESTAMP)] $DOMAIN WHOIS Updated"
    diff $NEW $OLD > $DIFF
    mail -s "Whois information of $DOMAIN changed at $TIMESTAMP UTC" root < $DIFF
    rm $DIFF
    else
    echo "[whois-watch.sh][$(TIMESTAMP)] $DOMAIN WHOIS Hasn't Changed"
    fi
    mv $NEW $OLD
    done
  3. wei revised this gist Jul 28, 2017. 1 changed file with 14 additions and 13 deletions.
    27 changes: 14 additions & 13 deletions whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -6,26 +6,27 @@
    # * * * * * /path/to/whois-watch.sh google.com
    # update username in mail command
    # update sed command depending on server return text
    # optional terminal-notifier
    # May need to update whois script to bypass verisign's search results (e.g. whois -h whois.verisign-grs.com "domain google.com")
    #

    DOMAIN=$1
    if [ -z "$DOMAIN" ]; then
    DOMAIN=GATECH.EDU
    fi
    OLD="/tmp/$DOMAIN.old.whois.txt"
    NEW="/tmp/$DOMAIN.new.whois.txt"
    DIFF="/tmp/$DOMAIN.whois.diff.txt"

    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
    echo 'not available' > /tmp/$DOMAIN.old.whois.txt
    if [ ! -f $OLD ]; then
    echo "not available" > $OLD
    fi
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    OLDFILE=$(/sbin/md5 /tmp/$DOMAIN.old.whois.txt | awk '{print $4}')
    NEWFILE=$(/sbin/md5 /tmp/$DOMAIN.new.whois.txt | awk '{print $4}')
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > $NEW
    OLDHASH=$(/sbin/md5 $OLD | awk '{print $4}')
    NEWHASH=$(/sbin/md5 $NEW | awk '{print $4}')

    if [ "$OLDFILE" != "$NEWFILE" ]; then
    diff /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt > /tmp/$DOMAIN.whois.diff.txt
    mail -s "Whois information of $DOMAIN changed" root < /tmp/$DOMAIN.whois.diff.txt
    #/usr/local/bin/terminal-notifier -title "$DOMAIN WHOIS Updated" -execute "mail" < /tmp/$DOMAIN.whois.diff.txt
    #rm /tmp/$DOMAIN.whois.diff.txt
    if [ "$OLDHASH" != "$NEWHASH" ]; then
    echo "$DOMAIN WHOIS Updated"
    diff $NEW $OLD > $DIFF
    mail -s "Whois information of $DOMAIN changed" root < $DIFF
    rm $DIFF
    fi
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
    mv $NEW $OLD
  4. wei revised this gist Jul 28, 2017. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -16,11 +16,9 @@ if [ -z "$DOMAIN" ]; then
    fi

    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.old.whois.txt
    echo 'not available' > /tmp/$DOMAIN.new.whois.txt
    else
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    echo 'not available' > /tmp/$DOMAIN.old.whois.txt
    fi
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    OLDFILE=$(/sbin/md5 /tmp/$DOMAIN.old.whois.txt | awk '{print $4}')
    NEWFILE=$(/sbin/md5 /tmp/$DOMAIN.new.whois.txt | awk '{print $4}')

  5. wei revised this gist Jun 29, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,12 @@
    # update username in mail command
    # update sed command depending on server return text
    # optional terminal-notifier
    # May need to update whois script to bypass verisign's search results (e.g. whois -h whois.verisign-grs.com "domain google.com")
    #

    DOMAIN=$1
    if [ -z "$DOMAIN" ]; then
    DOMAIN=GOOGLE.COM
    DOMAIN=GATECH.EDU
    fi

    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
  6. wei revised this gist Jun 29, 2016. 2 changed files with 32 additions and 26 deletions.
    26 changes: 0 additions & 26 deletions whois-change.sh
    Original file line number Diff line number Diff line change
    @@ -1,26 +0,0 @@
    #!/bin/bash

    #
    # Run this script once per day
    #

    DOMAIN="ZHOVNER.COM"


    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.old.whois.txt
    exit 0
    else
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    OLDFILE=$(md5sum /tmp/$DOMAIN.old.whois.txt | awk '{print $1}')
    NEWFILE=$(md5sum /tmp/$DOMAIN.new.whois.txt | awk '{print $1}')
    fi

    if [ "$OLDFILE" != "$NEWFILE" ]; then
    diff /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt > /tmp/$DOMAIN.whois.diff.txt
    mail -s "Whois information of $DOMAIN changed" root < /tmp/$DOMAIN.whois.diff.txt
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
    rm /tmp/$DOMAIN.whois.diff.txt
    else
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
    fi
    32 changes: 32 additions & 0 deletions whois-watch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash

    #
    # Run this script once per minute
    #
    # * * * * * /path/to/whois-watch.sh google.com
    # update username in mail command
    # update sed command depending on server return text
    # optional terminal-notifier
    #

    DOMAIN=$1
    if [ -z "$DOMAIN" ]; then
    DOMAIN=GOOGLE.COM
    fi

    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.old.whois.txt
    echo 'not available' > /tmp/$DOMAIN.new.whois.txt
    else
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    fi
    OLDFILE=$(/sbin/md5 /tmp/$DOMAIN.old.whois.txt | awk '{print $4}')
    NEWFILE=$(/sbin/md5 /tmp/$DOMAIN.new.whois.txt | awk '{print $4}')

    if [ "$OLDFILE" != "$NEWFILE" ]; then
    diff /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt > /tmp/$DOMAIN.whois.diff.txt
    mail -s "Whois information of $DOMAIN changed" root < /tmp/$DOMAIN.whois.diff.txt
    #/usr/local/bin/terminal-notifier -title "$DOMAIN WHOIS Updated" -execute "mail" < /tmp/$DOMAIN.whois.diff.txt
    #rm /tmp/$DOMAIN.whois.diff.txt
    fi
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
  7. @zhovner zhovner created this gist Jun 22, 2013.
    26 changes: 26 additions & 0 deletions whois-change.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/bin/bash

    #
    # Run this script once per day
    #

    DOMAIN="ZHOVNER.COM"


    if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.old.whois.txt
    exit 0
    else
    whois $DOMAIN | sed -e 's/^>>> Last update of whois database.*$//g' > /tmp/$DOMAIN.new.whois.txt
    OLDFILE=$(md5sum /tmp/$DOMAIN.old.whois.txt | awk '{print $1}')
    NEWFILE=$(md5sum /tmp/$DOMAIN.new.whois.txt | awk '{print $1}')
    fi

    if [ "$OLDFILE" != "$NEWFILE" ]; then
    diff /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt > /tmp/$DOMAIN.whois.diff.txt
    mail -s "Whois information of $DOMAIN changed" root < /tmp/$DOMAIN.whois.diff.txt
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
    rm /tmp/$DOMAIN.whois.diff.txt
    else
    mv /tmp/$DOMAIN.new.whois.txt /tmp/$DOMAIN.old.whois.txt
    fi