GitLab更新脚本

时间:2016-09-30 06:51:22

标签: bash gitlab

我尝试从源代码为GitLab安装编写更新脚本。

它可能有用。

我的问题是检查申请状态。 输出如下:

default... no 
Try fixing it:
sudo chmod -R ug+rwX,o-rwx /home/git/repositories/
sudo chmod -R ug-s /home/git/repositories/
sudo find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
For more information see:
doc/install/installation.md in section "GitLab Shell"

请修正上述错误并重新运行检查。

当我使用此命令时:

sudo -u ${GIT_USER} -H bundle exec rake gitlab:check RAILS_ENV=production

我想把sudo所在的行作为数组中的命令。 我怎么能这样做?

这是我的完整脚本:

#!/bin/bash
# Parameter checkup
if [ -n "${1}" ]
then
  GIT_USER="${1}"
else
  echo "Error: Usage ${0} <git username>"
fi

BASEDIR=`cat /etc/passwd | grep "${GIT_USER}" | cut -d":" -f 6`

GIT_SERVICE="gitlab"
GIT_TAG=`git for-each-ref --count=1 --sort=-taggerdate --format '%(tag)' refs/tags`
GIT_VERSION=`cat ${BASEDIR}/VERSION`

WEB_SERVICE="nginx"

echo "Updating GitLab ${GIT_VERSION} to ${GIT_TAG}.."

#  Stop server
echo "Stop server.."
service ${GIT_SERVICE} stop

# Get latest code for the stable branch
echo "Get latest code for the stable branch.."
cd "${BASEDIR}/gitlab"
sudo -u ${GIT_USER} -H git fetch --all
sudo -u ${GIT_USER} -H git checkout -- Gemfile.lock db/schema.rb
sudo -u ${GIT_USER} -H git checkout ${GIT_TAG} -b ${GIT_TAG}

# Update gitlab-shell to the corresponding version
echo "Update gitlab-shell to the corresponding version.."
cd "${BASEDIR}/gitlab-shell"
sudo -u ${GIT_USER} -H git fetch
sudo -u ${GIT_USER} -H git checkout v`cat "${BASEDIR}/gitlab/GITLAB_SHELL_VERSION"` -b v`cat "${BASEDIR}/gitlab/GITLAB_SHELL_VERSION"`

# Update gitlab-workhorse to the corresponding version
echo "Update gitlab-workhorse to the corresponding version.."
cd "${BASEDIR}/gitlab-workhorse"
sudo -u ${GIT_USER} -H git fetch
sudo -u ${GIT_USER} -H git checkout v`cat "${BASEDIR}/gitlab/GITLAB_WORKHORSE_VERSION"` -b v`cat "${BASEDIR}/gitlab/GITLAB_WORKHORSE_VERSION"`
sudo -u ${GIT_USER} -H make

# Install libs, migrations, etc.
echo "Install libs, migrations, etc.."
cd "${BASEDIR}/gitlab"
sudo -u ${GIT_USER} -H bundle install --without development test postgres --deployment
sudo -u ${GIT_USER} -H bundle clean
sudo -u ${GIT_USER} -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u ${GIT_USER} -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production

# Start application
echo "Start application.."
service ${GIT_SERVICE} start
service ${WEB_SERVICE} restart

# Check application status
echo "Check application status"
sudo -u ${GIT_USER} -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u ${GIT_USER} -H bundle exec rake gitlab:check RAILS_ENV=production

# default... no
# Try fixing it:
#  sudo chmod -R ug+rwX,o-rwx /home/git/repositories/
#  sudo chmod -R ug-s /home/git/repositories/
#  sudo find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
# For more information see:
# doc/install/installation.md in section "GitLab Shell"
# Please fix the error above and rerun the checks.

echo "Congratulations upgrade complete!"

有没有更好的方法来从源代码安装更新gitlab?

亲切的问候

0 个答案:

没有答案