From 2734f0a9fc8f6507779f695fa7c68d7e813d6fea Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Fri, 12 Feb 2016 17:32:34 +0530 Subject: [PATCH] check for empty db before overwriting --- debian/rake-tasks.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/debian/rake-tasks.sh b/debian/rake-tasks.sh index 968652cb30..aec5ee08e0 100755 --- a/debian/rake-tasks.sh +++ b/debian/rake-tasks.sh @@ -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'