2020-06-26 08:06:38 -07:00
|
|
|
#!/bin/bash
|
2020-06-26 08:12:30 -07:00
|
|
|
# diffweb: Check a website for changes
|
2020-06-26 08:04:31 -07:00
|
|
|
# Usage: diffweb https://domain.tld
|
|
|
|
|
# Author: Justin Oros
|
2020-06-26 08:12:30 -07:00
|
|
|
# Source: https://github.com/JustinOros/bash_scripts/blob/master/diffweb.sh
|
2020-06-26 08:04:31 -07:00
|
|
|
|
|
|
|
|
FILE1=/tmp/file1
|
|
|
|
|
FILE2=/tmp/file2
|
|
|
|
|
|
2020-06-26 08:09:55 -07:00
|
|
|
# check to see if any input was given
|
2020-06-26 08:04:31 -07:00
|
|
|
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
|
2020-06-26 08:09:55 -07:00
|
|
|
# notify user this is the first run
|
2020-06-26 08:04:31 -07:00
|
|
|
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
|
2020-06-26 08:09:55 -07:00
|
|
|
# compare files
|
|
|
|
|
if cmp -s $FILE1 $FILE2
|
|
|
|
|
then
|
|
|
|
|
# notify user website has not changed
|
|
|
|
|
echo "$1 has not changed."
|
|
|
|
|
else
|
|
|
|
|
# notify user website has changed
|
|
|
|
|
echo "$1 has been updated!"
|
|
|
|
|
# clone file2 to file1
|
|
|
|
|
cat $FILE2 > $FILE1
|
|
|
|
|
fi
|
2020-06-26 08:04:31 -07:00
|
|
|
fi
|