Check a website for changes

Usage: diffweb.sh https://domain.tld
This commit is contained in:
Justin Oros
2020-06-26 08:09:55 -07:00
committed by GitHub
parent 78182e5e6c
commit 78815cf4c4
+13 -12
View File
@@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
# diffweb - Checks a website for changes # diffweb - Checks a website for changes
# Usage: diffweb https://domain.tld # Usage: diffweb https://domain.tld
# Author: Justin Oros # Author: Justin Oros
@@ -8,6 +7,7 @@
FILE1=/tmp/file1 FILE1=/tmp/file1
FILE2=/tmp/file2 FILE2=/tmp/file2
# check to see if any input was given
if [ -z $1 ] if [ -z $1 ]
then then
echo "Usage: diffweb https://domain.tld" echo "Usage: diffweb https://domain.tld"
@@ -21,7 +21,7 @@ then # if file1 exists
# store to file2 # store to file2
curl -s $1 > $FILE2 curl -s $1 > $FILE2
else # if file1 does not exist else # if file1 does not exist
# notify user of first run # notify user this is the first run
echo "diffweb has not run before for $1" echo "diffweb has not run before for $1"
# get website data # get website data
# store to file1 # store to file1
@@ -31,14 +31,15 @@ fi
# check to see if file2 exists # check to see if file2 exists
if test -f $FILE2 if test -f $FILE2
then then
# compare files # compare files
if cmp -s $FILE1 $FILE2 if cmp -s $FILE1 $FILE2
then then
echo "$1 has not changed." # notify user website has not changed
else echo "$1 has not changed."
# notify user website has changed else
echo "$1 has been updated!" # notify user website has changed
# clone file2 to file1 echo "$1 has been updated!"
cat $FILE2 > $FILE1 # clone file2 to file1
fi cat $FILE2 > $FILE1
fi
fi fi