check for empty db before overwriting

This commit is contained in:
Praveen Arimbrathodiyil 2016-02-12 17:32:34 +05:30
parent 651f4d51d5
commit 2734f0a9fc

15
debian/rake-tasks.sh vendored
View file

@ -4,10 +4,17 @@
export $(cat /etc/gitlab/gitlab-debian.conf|xargs)
echo "Initializing database..."
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:setup RAILS_ENV=production'
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:shell:install \
REDIS_URL=redis://localhost:6379 \
SHELL_ROOT_PATH=/usr/share/gitlab-shell RAILS_ENV=production'
if [ "$(sudo -u postgres psql gitlab_production -c '\d')" = \
"No relations found." ]; then
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:setup \
RAILS_ENV=production force=yes'
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:shell:install \
REDIS_URL=redis://localhost:6379 \
SHELL_ROOT_PATH=/usr/share/gitlab-shell RAILS_ENV=production'
else
echo "gitlab_production database is not empty, skipping gitlab setup"
fi
echo "Precompiling assets..."
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake assets:precompile RAILS_ENV=production'