#!/bin/bash set -e GITLAB_VERSION=6.7.5 SHELL_VERSION=1.9.1 # add git user adduser --disabled-login --gecos 'GitLab' git sudo -u git -H mkdir -p /home/git/data/.ssh sudo -u git -H ln -s /home/git/data/.ssh /home/git/.ssh # create the data store sudo -u git -H mkdir -p /home/git/data # install gitlab-shell, use local copy if available sudo -u git -H mkdir -p /home/git/gitlab-shell if [ -f /app/setup/gitlab-shell-${SHELL_VERSION}.tar.gz ]; then sudo -u git -H tar -zvxf /app/setup/gitlab-shell-${SHELL_VERSION}.tar.gz --strip=1 -C /home/git/gitlab-shell/ else wget "https://github.com/gitlabhq/gitlab-shell/archive/v${SHELL_VERSION}.tar.gz" -O - | tar -zvxf - --strip=1 -C /home/git/gitlab-shell/ chown -R git:git /home/git/gitlab-shell/ fi cd /home/git/gitlab-shell sudo -u git -H cp -a config.yml.example config.yml sudo -u git -H ./bin/install # install gitlab, use local copy if available sudo -u git -H mkdir -p /home/git/gitlab if [ -f /app/setup/gitlabhq-${GITLAB_VERSION}.tar.gz ]; then sudo -u git -H tar -zvxf /app/setup/gitlabhq-${GITLAB_VERSION}.tar.gz --strip=1 -C /home/git/gitlab/ else wget "https://github.com/gitlabhq/gitlabhq/archive/v${GITLAB_VERSION}.tar.gz" -O - | tar -zvxf - --strip=1 -C /home/git/gitlab/ chown -R git:git /home/git/gitlab/ fi cd /home/git/gitlab # copy default configurations cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml sudo -u git -H cp config/resque.yml.example config/resque.yml sudo -u git -H cp config/database.yml.mysql config/database.yml sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb # create required tmp and log directories sudo -u git -H mkdir -p tmp/pids/ tmp/sockets/ chmod -R u+rwX log tmp # create symlink to uploads directory sudo -u git -H ln -s /home/git/data/uploads public/uploads # create symlink to backups directory sudo -u git -H ln -s /home/git/data/backups tmp/backups # create production log sudo -u git -H touch log/production.log # install gems required by gitlab, use local cache if available if [ -d "/app/setup/cache" ]; then # offline gem installation mv /app/setup/cache vendor/ chown -R git:git vendor/cache sudo -u git -H bundle install --local --deployment --without development test aws else # online gem installation sudo -u git -H bundle install --deployment --without development test aws fi # make sure everything in /home/git is owned by the git user chown -R git:git /home/git/ # install gitlab bootscript cp lib/support/init.d/gitlab /etc/init.d/gitlab chmod +x /etc/init.d/gitlab # install logrotate configuration cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab # copy nginx configuration ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab # configure supervisord to start nginx echo "daemon off;" >> /etc/nginx/nginx.conf cat > /etc/supervisor/conf.d/nginx.conf < /etc/supervisor/conf.d/mysqld.conf < /etc/supervisor/conf.d/redis-server.conf <