debian-mirror-gitlab/debian/rake-tasks.sh

46 lines
1.9 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
db_relations="$(LANG=C runuser -u postgres -- sh -c "psql gitlab_production -c \"\d\"" 2>&1)"
if [ "$db_relations" = "No relations found." ] || \
[ "$db_relations" = "Did not find any relations." ]; 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 \
"touch ${gitlab_data_dir}/.gitlab_shell_secret"
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:schema:load'
else
echo "gitlab_production database is not empty, skipping gitlab setup"
fi
runuser -u ${gitlab_user} -- sh -c 'bundle exec rake db:migrate'
# 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 'rm -rf node_modules/jquery'
runuser -u ${gitlab_user} -- sh -c 'npm install npm'
runuser -u ${gitlab_user} -- sh -c 'node_modules/.bin/npm install'
# workaround for broken libjs-jquery-atwho #890391
# npm i at.js won't work as it needs jquery@^1.7.0 as peer dependency
runuser -u ${gitlab_user} -- sh -c 'wget -O /tmp/at.js.tar.gz `npm view at.js dist.tarball`'
runuser -u ${gitlab_user} -- sh -c 'tar -C node_modules --transform "s/package/at.js/" -zxf /tmp/at.js.tar.gz'
runuser -u ${gitlab_user} -- sh -c 'npm i document-register-element@1.3.0'
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'