Created
March 31, 2022 23:15
-
-
Save carlfriess/afa477cc88b8211f39934d769fbd76dc to your computer and use it in GitHub Desktop.
Monitors a web page and sends a Pushover notification if it changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# monitor.sh - Monitors a web page for changes | |
# sends a Pushover notification if it changes | |
if [[ $# -ne 3 ]]; then | |
echo "Usage: $0 <url> <token> <user>" >&2 | |
exit 2 | |
fi | |
URL=$1 | |
TOKEN=$2 | |
USER=$3 | |
for (( ; ; )); do | |
mv new.html old.html 2> /dev/null | |
curl $URL -L --compressed -s > new.html | |
DIFF_OUTPUT="$(diff new.html old.html)" | |
if [[ "0" != "${#DIFF_OUTPUT}" ]]; then | |
curl "https://api.pushover.net/1/messages.json" -X POST -d "token=$TOKEN&user=$USER&message=$URL" | |
echo "It changed!" | |
else | |
echo "It didn't change!" | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment