Last active
November 21, 2023 18:00
-
-
Save RobThree/34a92d8db7a2e357897517a3de50fa7f to your computer and use it in GitHub Desktop.
gitlab version checker & notifier
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 | |
#mail recipient | |
RCPT=someone@gmail.com | |
#args: $rcpt $subject $text | |
sendnotification() { | |
echo -e "$3" | mail -s "$2" -t $1 | |
} | |
echo -n "Checking version: " | |
RESULT=`gitlab-checkversion` | |
echo ${RESULT} | |
if [ "${RESULT}" == "up-to-date" ] | |
then | |
echo -e "\e[32mOK\e[39m" | |
else | |
sendnotification "$RCPT" "New version for Gitlab available: ${RESULT}" "New version for Gitlab available: ${RESULT}" | |
exit 1 | |
fi |
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 | |
# Path to gitlab | |
GLPATH='/opt/gitlab/' | |
# Extract the version from the version-manifest | |
VERSION=`cat ${GLPATH}/version-manifest.txt | head -n 1 | grep -Po "[\d\.]*"` | |
# Create a Base64-encoded JSON string | |
VERSIONB64=`echo "{\"version\":\"$VERSION\"}" | base64` | |
# Request SVG | |
URL="https://version.gitlab.com/check.svg?gitlab_info=${VERSIONB64}" | |
# Extract content from SVG; we need a referrer otherwise we won't be served an image... | |
RESULT=`wget -q -O- --header="Referer: https://google.com" ${URL} | grep -oPm1 "(?<=\">)(.*)<\/text>" | grep -oP ".+?(?=<\/text>)"` | |
# Return result to stdout | |
echo ${RESULT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment