2015-09-12 15:42:12 +05:30
|
|
|
#! /bin/sh
|
2016-02-09 22:41:02 +05:30
|
|
|
# Read and export debian specific configuration
|
|
|
|
# Only exported variables will be passed on to gitlab app
|
2016-02-18 17:53:04 +05:30
|
|
|
export $(cat /etc/gitlab/gitlab-debian.conf)
|
2016-02-04 13:31:45 +05:30
|
|
|
|
2016-02-18 18:12:32 +05:30
|
|
|
if ! [ -f "${gitlab_app_root}/config/secrets.yml" ]; then
|
|
|
|
echo "Creating secrets.yml..."
|
2016-02-18 22:00:42 +05:30
|
|
|
# Check if .secret file exist already in gitlab_app_root
|
|
|
|
# See if it is an empty file
|
|
|
|
test -e ${gitlab_app_root}/.secret &&\
|
|
|
|
gitlab_app_secret=$(cat ${gitlab_app_root}/.secret);\
|
|
|
|
test -n "${gitlab_app_secret}" ||\
|
|
|
|
{ gitlab_app_secret=$(openssl rand -hex 64)
|
|
|
|
|
2016-02-18 18:12:32 +05:30
|
|
|
cp ${gitlab_app_root}/config/secrets.yml.example ${gitlab_app_root}/config/secrets.yml
|
|
|
|
sed -i "s/# db_key_base:/db_key_base: ${gitlab_app_secret}/" ${gitlab_app_root}/config/secrets.yml
|
2016-02-18 22:00:42 +05:30
|
|
|
echo ${gitlab_app_root} > ${gitlab_app_root}/.secret
|
|
|
|
}
|
2016-02-18 18:12:32 +05:30
|
|
|
fi
|
2015-09-12 15:42:12 +05:30
|
|
|
echo "Initializing database..."
|
2016-02-13 23:52:29 +05:30
|
|
|
if [ "$(su postgres -c 'psql gitlab_production -c \\d')" = \
|
2016-02-12 17:32:34 +05:30
|
|
|
"No relations found." ]; then
|
|
|
|
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:setup \
|
|
|
|
RAILS_ENV=production force=yes'
|
|
|
|
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:shell:install \
|
|
|
|
REDIS_URL=redis://localhost:6379 \
|
|
|
|
SHELL_ROOT_PATH=/usr/share/gitlab-shell RAILS_ENV=production'
|
|
|
|
else
|
|
|
|
echo "gitlab_production database is not empty, skipping gitlab setup"
|
|
|
|
fi
|
|
|
|
|
2015-09-12 15:42:12 +05:30
|
|
|
echo "Precompiling assets..."
|
2015-11-09 00:12:39 +05:30
|
|
|
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake assets:precompile RAILS_ENV=production'
|
2016-01-23 23:02:18 +05:30
|
|
|
|
|
|
|
# Start gitlab
|
2016-02-12 01:02:03 +05:30
|
|
|
if [ -d "/run/systemd/system" ]; then
|
|
|
|
systemctl start gitlab.target
|
2016-02-04 15:33:53 +05:30
|
|
|
else
|
2016-02-12 01:02:03 +05:30
|
|
|
invoke-rc.d gitlab start
|
2016-02-04 15:33:53 +05:30
|
|
|
fi
|
2016-01-23 23:02:18 +05:30
|
|
|
|
2016-02-09 20:51:38 +05:30
|
|
|
# Workaround for #813770
|
|
|
|
if [ "${GITLAB_HTTPS}" = "true" ]; then
|
|
|
|
gl_proto="https"
|
2016-02-18 14:31:41 +05:30
|
|
|
sed -i "s/#port: 80/port: 443/" ${gitlab_app_root}/config/gitlab.yml
|
|
|
|
sed -i "s/https: false/https: true/" ${gitlab_app_root}/config/gitlab.yml
|
2016-02-09 20:51:38 +05:30
|
|
|
else
|
|
|
|
gl_proto="http"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i \
|
2016-02-09 23:39:08 +05:30
|
|
|
"s/gitlab_url: http*:\/\/.*/gitlab_url: ${gl_proto}:\/\/${GITLAB_HOST}/"\
|
2016-02-09 21:45:06 +05:30
|
|
|
${gitlab_shell_root}/config.yml
|
2016-02-09 20:51:38 +05:30
|
|
|
|
2016-01-23 23:02:18 +05:30
|
|
|
# Check gitlab is configured correctly
|
2016-01-16 02:16:50 +05:30
|
|
|
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake gitlab:check RAILS_ENV=production'
|
2015-09-12 15:42:12 +05:30
|
|
|
|