最終更新 6 months ago

gitlab_source_minor_version_update.sh Raw
1#!/bin/sh
2if [ -z "${1}" ]
3then
4 echo "Specify which database are you using: [ --mysql | --postgresql ]"
5 exit 0
6fi
7case ${1} in
8 --mysql)
9 BUNDLE_EXCLUDE="postgres"
10 ;;
11 --postgresql)
12 BUNDLE_EXCLUDE="mysql"
13 ;;
14 *)
15 echo "Specify which database are you using: [ --mysql | --postgresql ]"
16 exit 0
17 ;;
18esac
19
20# backup
21cd /home/git/gitlab
22sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
23# stop server
24sudo service gitlab stop
25# get latest code from stable branch
26cd /home/git/gitlab
27sudo -u git -H git fetch --all
28sudo -u git -H git checkout -- Gemfile.lock db/schema.rb
29LATEST_TAG=$(git tag -l 'v*.[0-9]' --sort='v:refname'| tail -1)
30#LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
31sudo -u git -H git checkout $LATEST_TAG -b $LATEST_TAG
32# updating git-shell to corresponding version
33cd /home/git/gitlab-shell
34sudo -u git -H git fetch
35sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION` -b v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
36# update gitlab-workhorse to the corresponding version
37cd /home/git/gitlab-workhorse
38sudo -u git -H git fetch
39sudo -u git -H git checkout `cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION` -b `cat /home/git/gitlab/GITLAB_WORKHORSE_VERSION` && sudo -u git -H make
40# install libs, migrations, etc.
41cd /home/git/gitlab
42sudo -u git -H bundle install --without development test ${BUNDLE_EXCLUDE} --deployment
43sudo -u git -H bundle clean
44sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
45sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
46# start application
47sudo service gitlab start
48sudo service nginx restart
49# check application status
50sudo -u git -H bundle exec rake gitlab:env:info gitlab:check RAILS_ENV=production
51