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