Skip to content

Instantly share code, notes, and snippets.

@valeriansaliou
Last active August 29, 2015 14:20
Show Gist options
  • Save valeriansaliou/ef53dcbfec3170f57437 to your computer and use it in GitHub Desktop.
Save valeriansaliou/ef53dcbfec3170f57437 to your computer and use it in GitHub Desktop.
GitLab Upgrade Scripts
#!/bin/sh
if [ "$1" ]; then
# Upgrade both GitLab CE + GitLab CI
upgrade_gitlab_ce "$1";
upgrade_gitlab_ci "$1";
else
echo "[upgrade_gitlab] Please feed me with upgrade branch (X-X-stable)"
fi
#!/bin/sh
if [ "$1" ]; then
# Update GitLab filesystem
update_gitlab()/
{
cd /home/git/gitlab;
sudo service gitlab stop;
sudo -u git -H git fetch --all;
sudo -u git -H git checkout -- db/schema.rb;
sudo -u git -H git checkout "$1";
}
# Update GitLab Shell
update_gitlab_shell()
{
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`;
sudo -u git -H bundle exec rake gitlab:shell:install[v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production;
}
# Deploy GitLab
deploy_gitlab()
{
cd /home/git/gitlab;
sudo -u git -H bundle install --without development test postgres --deployment;
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;
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab;
sed -i "s/\/home\//\/srv\/data_agency\//g" /etc/init.d/gitlab;
}
# Restart daemons
restart_daemons()
{
sudo systemctl daemon-reload;
sudo service gitlab start;
sudo service nginx restart;
}
# Check new setup
check_setup()
{
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production;
}
# Run upgrade flow
update_gitlab "$1";
update_gitlab_shell;
deploy_gitlab;
restart_daemons;
check_setup;
else
echo "[upgrade_gitlab_ce] Please feed me with upgrade branch (X-X-stable)"
fi
#!/bin/sh
if [ "$1" ]; then
# Update GitLab CI filesystem
update_gitlab_ci()
{
cd /home/gitlab_ci/gitlab-ci;
sudo service gitlab_ci stop;
sudo -u gitlab_ci -H git fetch;
sudo -u gitlab_ci -H git checkout -- db/schema.rb;
sudo -u gitlab_ci -H git checkout "$1";
}
# Deploy GitLab CI
deploy_gitlab_ci()
{
sudo -u gitlab_ci -H bundle install --without postgres development test --deployment;
sudo -u gitlab_ci -H bundle exec rake db:migrate RAILS_ENV=production;
sudo systemctl daemon-reload;
sudo service gitlab_ci start;
sudo service nginx restart;
}
# Run upgrade flow
update_gitlab_ci "$1";
deploy_gitlab_ci;
else
echo "[upgrade_gitlab_ci] Please feed me with upgrade branch (X-X-stable)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment