2015-09-12 15:42:12 +05:30
|
|
|
#! /bin/sh
|
2016-09-26 10:19:28 +05:30
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2017-03-17 22:27:14 +05:30
|
|
|
# Read debian specific configuration
|
|
|
|
. /etc/gitlab/gitlab-debian.conf
|
|
|
|
export DB RAILS_ENV
|
|
|
|
|
2016-09-26 10:19:28 +05:30
|
|
|
cd /usr/share/gitlab
|
2016-02-04 13:31:45 +05:30
|
|
|
|
2016-04-05 21:12:05 +05:30
|
|
|
# Check if the db is already present
|
2017-04-21 15:03:54 +05:30
|
|
|
if [ "$(LANG=C runuser -u postgres -- sh -c "psql gitlab_production -c \"\d\"")" = \
|
2016-04-04 22:39:31 +05:30
|
|
|
"No relations found." ]; then
|
|
|
|
echo "Initializing database..."
|
2016-10-01 15:08:03 +05:30
|
|
|
test -f ${gitlab_home}/db/schema.rb || \
|
2017-04-21 15:03:54 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c \
|
2016-10-01 16:37:22 +05:30
|
|
|
"cp ${gitlab_data_dir}/db/schema.rb.template ${gitlab_data_dir}/db/schema.rb"
|
2017-04-21 15:03:54 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:schema:load'
|
|
|
|
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:seed_fu'
|
2016-04-04 22:39:31 +05:30
|
|
|
else
|
|
|
|
echo "gitlab_production database is not empty, skipping gitlab setup"
|
2017-04-21 15:03:54 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:migrate'
|
2016-04-04 22:39:31 +05:30
|
|
|
fi
|
2016-02-12 17:32:34 +05:30
|
|
|
|
2016-04-05 21:12:05 +05:30
|
|
|
# Restrict permissions for secret files
|
|
|
|
chmod 0700 ${gitlab_data_dir}/.gitlab_shell_secret
|
|
|
|
|
2017-08-22 16:38:25 +05:30
|
|
|
echo "Installing node modules"
|
2017-08-22 19:19:31 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'install -d /var/lib/gitlab/node_modules'
|
2017-08-22 16:38:25 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'npm install'
|
2017-09-09 22:17:18 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'rm -rf node_modules/webpack'
|
2017-09-04 10:51:38 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'NODE_PATH=/usr/share/gitlab/node_modules webpack --config config/webpack.config.js'
|
2017-08-22 16:38:25 +05:30
|
|
|
|
2015-09-12 15:42:12 +05:30
|
|
|
echo "Precompiling assets..."
|
2017-04-21 15:03:54 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake tmp:cache:clear assets:precompile'
|