From a3774f593d85769184cef108341ae8745a568256 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Fri, 26 Jun 2020 08:04:31 -0700 Subject: [PATCH] Checks a website for changes Usage: diffweb https://domain.tld --- diffweb | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 diffweb diff --git a/diffweb b/diffweb new file mode 100644 index 0000000..14ceaad --- /dev/null +++ b/diffweb @@ -0,0 +1,42 @@ +# diffweb - Notify user if a website has changed +# Usage: diffweb https://domain.tld +# Author: Justin Oros +# Revised: 2020 JUNE 25 + +FILE1=/tmp/file1 +FILE2=/tmp/file2 + +if [ -z $1 ] +then + echo "Usage: diffweb https://domain.tld" + exit 1 +fi + +# check to see if file1 exists +if test -f $FILE1 +then # if file1 exists + # get website data + # store to file2 + curl -s $1 > $FILE2 +else # if file1 does not exist + # notify user of first run + echo "diffweb has not run before for $1" + # get website data + # store to file1 + curl -s $1 > $FILE1 +fi + +# check to see if file2 exists +if test -f $FILE2 +then + # compare files + if cmp -s $FILE1 $FILE2 + then + echo "$1 has not changed." + else + # notify user website has changed + echo "$1 has been updated!" + # clone file2 to file1 + cat $FILE2 > $FILE1 + fi +fi