debian-mirror-gitlab/debian/rake-tasks.sh
2017-09-09 22:17:18 +05:30

37 lines
1.5 KiB
Bash
Executable file

#! /bin/sh
set -e
# Read debian specific configuration
. /etc/gitlab/gitlab-debian.conf
export DB RAILS_ENV
cd /usr/share/gitlab
# Check if the db is already present
if [ "$(LANG=C runuser -u postgres -- sh -c "psql gitlab_production -c \"\d\"")" = \
"No relations found." ]; then
echo "Initializing database..."
test -f ${gitlab_home}/db/schema.rb || \
runuser -u ${gitlab_user} -- sh -c \
"cp ${gitlab_data_dir}/db/schema.rb.template ${gitlab_data_dir}/db/schema.rb"
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:schema:load'
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:seed_fu'
else
echo "gitlab_production database is not empty, skipping gitlab setup"
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:migrate'
fi
# Restrict permissions for secret files
chmod 0700 ${gitlab_data_dir}/.gitlab_shell_secret
echo "Installing node modules"
runuser -u ${gitlab_user} -- sh -c 'install -d /var/lib/gitlab/node_modules'
runuser -u ${gitlab_user} -- sh -c 'npm install'
runuser -u ${gitlab_user} -- sh -c 'ln -s /usr/lib/nodejs/exports-loader node_modules'
runuser -u ${gitlab_user} -- sh -c 'ln -s /usr/lib/nodejs/raw-loader node_modules'
runuser -u ${gitlab_user} -- sh -c 'rm -rf node_modules/webpack'
runuser -u ${gitlab_user} -- sh -c 'NODE_PATH=/usr/share/gitlab/node_modules webpack --config config/webpack.config.js'
echo "Precompiling assets..."
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake tmp:cache:clear assets:precompile'