From 6206489e191dc9139d7c60875fb94428fd91da22 Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Mon, 4 Apr 2016 22:39:31 +0530 Subject: [PATCH] use unicode, check db exist --- debian/changelog | 2 ++ debian/postinst | 2 +- debian/rake-tasks.sh | 17 +++++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 81a7298fd0..1e31096207 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ gitlab (8.5.8+dfsg-3) UNRELEASED; urgency=medium * Symlink 'shared' to /var/lib/gitlab instead of 'shared/cache' - gitlab expects everything inside shared to be in the same file system. * Use embedded copy of fuzzaldrin-plus (See #814871 for more details) + * Bring back db check in postinst (initialize the db only if it is empty) + * Choose unicode for db encoding (fixes wiki creation error) -- Pirate Praveen Sun, 03 Apr 2016 17:41:28 +0530 diff --git a/debian/postinst b/debian/postinst index 099e135f0f..f8f9ba2130 100755 --- a/debian/postinst +++ b/debian/postinst @@ -126,7 +126,7 @@ case "$1" in echo "Create database if not present" if ! su postgres -s /bin/sh -c "psql gitlab_production -c ''"; then - su postgres -c 'createdb gitlab_production' + su postgres -c 'createdb -E unicode -T template0 gitlab_production' fi # Adjust database privileges diff --git a/debian/rake-tasks.sh b/debian/rake-tasks.sh index 0f6066363a..d23e964886 100755 --- a/debian/rake-tasks.sh +++ b/debian/rake-tasks.sh @@ -17,12 +17,17 @@ if ! [ -f "${gitlab_app_root}/config/secrets.yml" ]; then echo ${gitlab_app_root} > ${gitlab_app_root}/.secret } fi -echo "Initializing database..." -su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:schema:load' -su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:seed_fu' -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 [ "$(LANG=C su postgres -c "psql gitlab_production -c \"\d\"")" = \ +"No relations found." ]; then + echo "Initializing database..." + su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:schema:load' + su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:seed_fu' + 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'