#!/bin/bashI haven't tested this script on a CentOS machine so it might need some adjustments to work there.
OS="ubuntu"
OS_Version="14.04"
OS_ARCHITECTURE="amd64"
# Ubuntu/Debian:
INSTALLED_VERSION=$(dpkg -s gitlab | grep -i version | cut -d" " -f2)
# CentOS:
#INSTALLED_VERSION=$(rpm -qa | grep omnibus)
# Uses sort -V to compare versions
LATEST=$(wget -q -O- https://about.gitlab.com/downloads/archives/ | grep -i "$OS" | grep -i "$OS_VERSION" | grep -i $OS_ARCHITECTURE | grep -Eo 'href=".*"' | cut -d'"' -f2 | sort -V | tail -n 1)
PACKAGE=${LATEST##*/}
LATEST_VERSION=$(echo $PACKAGE | cut -d_ -f2)
echo ""
echo " Current version: $INSTALLED_VERSION"
echo " Latest version: $LATEST_VERSION"
if [[ "$INSTALLED_VERSION" != "$LATEST_VERSION" && "$LATEST_VERSION" != "" ]]; then
echo " Update to $LATEST_VERSION available!"
echo -n " Do you wich to upgrade? [y/N]? "
read answer
case $answer in
y*)
# Backup branding:
cp /opt/gitlab/embedded/service/gitlab-rails/public/assets/*logo*.png /tmp/
wget $LATEST
# Stop unicorn and sidekiq so we can do database migrations
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
# Create a database backup in case the upgrade fails
sudo gitlab-rake gitlab:backup:create
# Install the latest package
# Ubuntu/Debian:
sudo dpkg -i $PACKAGE
# CentOS:
#sudo rpm -Uvh $PACKAGE
# Restore branding:
sudo cp /tmp/*logo*.png /opt/gitlab/embedded/service/gitlab-rails/public/assets/
# Reconfigure GitLab (includes database migrations)
sudo gitlab-ctl reconfigure
# Restart all gitlab services
sudo gitlab-ctl restart
rm $PACKAGE
;;
*)
echo "No change"
;;
esac
else
echo " Nothing to do!"
fi
echo ""
Showing posts with label GitLab. Show all posts
Showing posts with label GitLab. Show all posts
Saturday, 30 August 2014
GitLab update script
I've recently installed GitLab and they provide easy to install deb and rpm packages but not a repository to help us keep our installation up to date. So I developed the following script that will check https://about.gitlab.com/downloads/archives/ for newer versions and install them when available:
Possibly Related Posts
Subscribe to:
Comments (Atom)