-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from silversword411/main
missed one From Discord #scripts Thanks Stefan!
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# | ||
# With love from Stefan Lousberg 10/29/2023 | ||
# Env Var: URL=https://www.google.nl | ||
# Args: words | ||
# | ||
|
||
# URL to monitor (specified as an environment variable) | ||
URL="$URL" | ||
|
||
# Keywords to monitor for (passed as script arguments) | ||
KEYWORDS=("$@") | ||
|
||
# Perform the cURL request and store the page content in a variable | ||
PAGE_CONTENT=$(curl -s "$URL") | ||
|
||
found_all_keywords=1 | ||
|
||
# Loop through each keyword and check if it exists in the page content | ||
for keyword in "${KEYWORDS[@]}"; do | ||
if [[ $PAGE_CONTENT != *"$keyword"* ]]; then | ||
echo "Keyword '$keyword' not found on $URL" | ||
found_all_keywords=0 | ||
fi | ||
done | ||
|
||
if [ "$found_all_keywords" -eq 1 ]; then | ||
echo "All keywords found on $URL" | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |