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

52 lines
1.8 KiB
Bash
Raw Normal View History

2015-09-12 15:42:12 +05:30
#! /bin/sh
# 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-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-04-05 12:37:43 +05:30
echo ${gitlab_app_secret} > ${gitlab_app_root}/.secret
2016-02-18 22:00:42 +05:30
}
2016-04-05 12:37:43 +05:30
2016-04-05 21:06:24 +05:30
fi
2016-04-05 12:37:43 +05:30
# Check if the db is already present
2016-04-04 22:39:31 +05:30
if [ "$(LANG=C su postgres -c "psql gitlab_production -c \"\d\"")" = \
"No relations found." ]; then
echo "Initializing database..."
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:schema:load'
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:seed_fu'
else
echo "gitlab_production database is not empty, skipping gitlab setup"
2016-04-05 12:17:23 +05:30
su ${gitlab_user} -s /bin/sh -c 'bundle exec rake db:migrate'
2016-04-04 22:39:31 +05:30
fi
2016-02-12 17:32:34 +05:30
# Restrict permissions for secret files
chown ${gitlab_user}: ${gitlab_data_dir}/.secret
chmod 0700 ${gitlab_data_dir}/.secret
chmod 0700 ${gitlab_data_dir}/.gitlab_shell_secret
2016-04-05 21:31:44 +05:30
chown ${gitlab_user}: ${gitlab_app_root}/config/secrets.yml
chmod 0700 ${gitlab_app_root}/config/secrets.yml
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
printf "Starting GitLab...\n"
service gitlab start
2016-01-23 23:02:18 +05:30
# Check gitlab is configured correctly
printf "Check if Gitlab is configured correctly...\n"
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