Last active
March 19, 2024 16:40
-
-
Save gastaldi/0b00da0cb566eb0d0ec6101bbb7acf86 to your computer and use it in GitHub Desktop.
monitor.sh
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 | |
: ${1:?"groupId is required"} | |
: ${2:?"artifactId is required"} | |
: ${3:?"version is required"} | |
# eg. ~/monitor.sh org.wildfly.swarm spi 1.0.8.Final | |
GROUP_ID=${1//.//} | |
ARTIFACT_ID=$2 | |
VERSION=$3 | |
URL="https://repo1.maven.org/maven2/$GROUP_ID/$ARTIFACT_ID/$VERSION/$ARTIFACT_ID-$VERSION.pom" | |
echo Monitoring $URL | |
for (( ; ; )); do | |
STATUS_CODE="$(curl -I --stderr /dev/null $URL | head -1 | cut -d' ' -f2)" | |
#echo Status code: $STATUS_CODE | |
if [ "200" == "$STATUS_CODE" ]; then | |
notify-send "Artifact ${GROUP_ID////.}:$ARTIFACT_ID:$VERSION is now available!" | |
# On macOS use the below: | |
# terminal-notifier -message "Artifact ${GROUP_ID////.}:$ARTIFACT_ID:$VERSION is now available!" -title "Monitor Artifact Availability" -open $URL | |
exit | |
fi | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment