From: Gustav Eek Date: Tue, 28 May 2024 07:08:32 +0000 (+0200) Subject: [watchsite] Initial commit on watchsite script X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=2e31f7434ef921b6a427322d4a25adacfdf11585;p=users%2Fgustav%2Fscripts.git [watchsite] Initial commit on watchsite script The script is fully functioning but simple --- diff --git a/Makefile b/Makefile index 85e10db..9d4bc2d 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ SCRIPTS = \ msmtp-notify \ repo-encrypt \ unoconv-display \ + watchsite \ yaml2json \ BASH_COMPLETION = \ diff --git a/watchsite b/watchsite new file mode 100644 index 0000000..8c61744 --- /dev/null +++ b/watchsite @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +HELP="Usage: watchsite [-h] URL PATTERN + +Whatch a website for a pattern and send an alarm email when found. + +PARAMETERS + + EMAIL read as environmental variable + +" + +DEFAULT_EMAIL="gustav.eek@fripost.org" +SLEEP=3600 + +if [ "$1" == "-h" ]; then + echo "$HELP" + exit +fi + +if [ -z "$EMAIL" ]; then + email="$DEFAULT_EMAIL" +else + email="$EMAIL" +fi + +url="$1" +ptrn="$2" + +text="from: $email +to: $email +subject: Watchsite result found + +Check result of '$ptrn' at <$url> ! +" + +while true; do + if curl -sL "$url" | grep -qi "$ptrn"; then + echo "$text" | msmtp "$email" + exit + fi + sleep $SLEEP +done + + + +