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

49 lines
2 KiB
Bash
Raw Normal View History

2015-09-12 15:42:12 +05:30
#! /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
2017-12-13 00:51:58 +05:30
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
2016-04-04 22:39:31 +05:30
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 \
"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 '/usr/bin/bundle exec rake db:schema:load'
2016-04-04 22:39:31 +05:30
else
echo "gitlab_production database is not empty, skipping gitlab setup"
fi
2016-02-12 17:32:34 +05:30
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake db:migrate'
2017-12-13 00:51:58 +05:30
# Restrict permissions for secret files
chmod 0700 ${gitlab_data_dir}/.gitlab_shell_secret
2018-02-23 00:00:41 +05:30
echo "Installing node modules..."
2018-03-22 21:16:18 +05:30
runuser -u ${gitlab_user} -- sh -c 'install -d /var/lib/gitlab/.node_modules'
runuser -u ${gitlab_user} -- sh -c 'install -d /var/lib/gitlab/yarn'
runuser -u ${gitlab_user} -- sh -c 'cd /var/lib/gitlab/yarn; npm install yarn'
2018-10-18 17:13:12 +05:30
runuser -u ${gitlab_user} -- sh -c '/var/lib/gitlab/yarn/node_modules/.bin/yarn --frozen-lockfile install'
# Remove write permissions of .yarn-metadata.json files
runuser -u ${gitlab_user} -- sh -c 'find /var/lib/gitlab/.cache/yarn/v4/ -name .yarn-metadata.json -perm -a=w -exec chmod 644 {} \;'
echo "Precompiling locales..."
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake gettext:po_to_json'
2015-09-12 15:42:12 +05:30
echo "Precompiling assets..."
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake tmp:cache:clear assets:precompile'
echo "Webpacking..."
2018-05-02 17:29:48 +05:30
#runuser -u ${gitlab_user} -- sh -c 'rm -rf node_modules/webpack'
#runuser -u ${gitlab_user} -- sh -c 'rm -rf node_modules/webpack-bundle-analyzer'
runuser -u ${gitlab_user} -- sh -c 'node_modules/.bin/webpack --config config/webpack.config.js'