Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Created April 28, 2014 15:29
Show Gist options
  • Save samrocketman/11375488 to your computer and use it in GitHub Desktop.
Save samrocketman/11375488 to your computer and use it in GitHub Desktop.
A simple bash script for checking the latest stable version of GitLab
#!/bin/bash
#Sam Gleske
#Mon Apr 28 11:11:10 EDT 2014
#Red Hat Enterprise Linux Server release 6.5 (Santiago)
#Linux 2.6.32-431.el6.x86_64 x86_64
#GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
#DESCRIPTION
# Check the latest stable version and compare with the version of gitlab installed.
# Run daily via cron.
#gitlab user
gitlab_user="gitlab"
gitlab_home="/app/${gitlab_user}"
csv_email="[email protected]"
cd "${gitlab_home}/gitlab"
latest_stable="$(git ls-remote 2> /dev/null | grep heads | tail -n2 | head -n1 | cut -d '/' -f3)"
latest_stable_version="$(curl "https://gitlab.com/gitlab-org/gitlab-ce/raw/${latest_stable}/VERSION" 2> /dev/null)"
current_version="$(head -n1 ./VERSION)"
if [ ! "${current_version}" = "${latest_stable_version}" ];then
echo "New version of GitLab! Currently Installed = ${current_version}; Latest = ${latest_stable_version}" 1>&2
#send an email notification
sendmail "${csv_email}" <<EOF
To: ${csv_email}
Subject: New version of GitLab! Latest = ${latest_stable_version}
Currently installed GitLab = ${current_version}
Latest GitLab version = ${latest_stable_version}
EOF
#exit with a POSIX failure code
exit 1
else
#exit with a POSIX success code
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment