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
|
|
|
|
2020-12-07 19:41:39 +05:30
|
|
|
# Workaround for #966653
|
|
|
|
/usr/bin/gem install -v 1.30.2 grpc
|
2021-02-19 14:12:52 +05:30
|
|
|
# Remove all lines from Gemfile.lock
|
|
|
|
runuser -u ${gitlab_user} -- sh -c "touch ${gitlab_data_dir}/Gemfile.lock && \
|
|
|
|
truncate -s 0 ${gitlab_data_dir}/Gemfile.lock"
|
|
|
|
# Regenerate Gemfile.lock
|
2020-12-07 19:41:39 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle install --local'
|
|
|
|
|
2016-04-05 21:12:05 +05:30
|
|
|
# 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..."
|
2020-06-27 22:49:49 +05:30
|
|
|
test -f ${gitlab_home}/db/structure.sql || \
|
2017-04-21 15:03:54 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c \
|
2020-06-27 22:49:49 +05:30
|
|
|
"cp ${gitlab_data_dir}/db/structure.sql.template ${gitlab_data_dir}/db/structure.sql"
|
2017-12-25 23:50:56 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c \
|
|
|
|
"touch ${gitlab_data_dir}/.gitlab_shell_secret"
|
2019-03-06 19:57:08 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'touch /var/lib/gitlab/secrets.yml'
|
2020-06-27 22:49:49 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake db:structure: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
|
|
|
|
2018-12-18 12:14:07 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake db:migrate'
|
2017-12-13 00:51:58 +05:30
|
|
|
|
2016-04-05 21:12:05 +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..."
|
2020-12-21 20:48:56 +05:30
|
|
|
cd /var/lib/gitlab
|
2020-06-27 22:49:49 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'install -d /var/lib/gitlab/.cache'
|
2020-12-21 03:16:23 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'yarnpkg set version berry'
|
|
|
|
runuser -u ${gitlab_user} -- sh -c 'if ! grep nodeLinker .yarnrc.yml >/dev/null; then echo "nodeLinker: \"node-modules\"" >>.yarnrc.yml; fi'
|
2019-05-18 01:30:26 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'yarnpkg install'
|
2018-12-15 00:23:51 +05:30
|
|
|
# Remove write permissions of .yarn-metadata.json files
|
2019-11-29 20:56:11 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'test -d "/var/lib/gitlab/.cache/yarn/v6" && find /var/lib/gitlab/.cache/yarn/v6/ -name .yarn-metadata.json -perm -a=w -exec chmod 644 {} \;'
|
2018-02-25 19:11:11 +05:30
|
|
|
|
2020-12-21 20:48:56 +05:30
|
|
|
cd /usr/share/gitlab
|
|
|
|
|
2018-03-01 23:45:05 +05:30
|
|
|
echo "Precompiling locales..."
|
2018-12-18 12:14:07 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake gettext:po_to_json'
|
2017-08-22 16:38:25 +05:30
|
|
|
|
2015-09-12 15:42:12 +05:30
|
|
|
echo "Precompiling assets..."
|
2018-12-18 12:14:07 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c '/usr/bin/bundle exec rake tmp:cache:clear assets:precompile'
|
2018-02-25 19:11:11 +05:30
|
|
|
|
2018-03-01 23:45:05 +05:30
|
|
|
echo "Webpacking..."
|
2020-04-11 00:46:45 +05:30
|
|
|
# Workaround for webpack crashing with nodejs 10 - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956211
|
2020-04-12 13:46:22 +05:30
|
|
|
# Build assets in production mode - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956508
|
2020-12-21 20:48:56 +05:30
|
|
|
runuser -u ${gitlab_user} -- sh -c 'NODE_ENV="production" NODE_PATH="node_modules" NODE_OPTIONS="--max-old-space-size=4096" webpack --config config/webpack.config.js'
|