-
-
Save sgraham785/368bb2ed2e50cbe05c96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm | |
curl -L https://get.rvm.io | bash -s stable | |
source /etc/profile.d/rvm.sh | |
rvm install 2.0.0 | |
rvm use 2.0.0@global --default | |
### install bundler and rails | |
gem install bundler --no-ri --no-rdoc | |
gem install rails --no-ri --no-rdoc | |
### install dep-packages | |
yum -y update | |
yum -y install wget curl gcc libxml2-devel libxslt-devel make openssh-server libyaml-devel postfix libicu-devel libcurl-devel libcurl readline-devel readline glibc glibc-devel openssl-devel openssl mysql++-devel postgresql-devel zlib-devel git | |
yum -y install redis | |
yum -y install nginx | |
# install postgres | |
rpm -U http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm | |
yum -y install postgresql93-server | |
chkconfig nginx on | |
chkconfig postgresql-9.3 on | |
chkconfig redis on | |
### start redis server | |
### otherwise the `Background Jobs` page says "Internal Server Error" | |
service redis start | |
### user gitlab_ci | |
useradd --comment 'GitLab CI' -m gitlab_ci | |
service postgresql-9.3 initdb | |
# Login to PostgreSQL | |
sudo -u postgres psql -d template1 | |
# Create a user for GitLab. We do not specify a password because we are using peer authentication. | |
template1=# CREATE USER gitlab_ci; | |
# Create the GitLab production database & grant all privileges on database | |
template1=# CREATE DATABASE gitlab_ci_production OWNER gitlab_ci; | |
# Quit the database session | |
template1=# \q | |
# Try connecting to the new database with the new user | |
sudo -u gitlab_ci -H psql -d gitlab_ci_production | |
### get the code | |
cd /home/gitlab_ci/ | |
sudo -u gitlab_ci -H git clone https://gitlab.com/gitlab-org/gitlab-ci.git | |
cd gitlab-ci | |
sudo -u gitlab_ci -H git checkout 5-0-stable | |
# Edit application settings | |
# Production | |
sudo -u gitlab_ci -H cp config/application.yml.example config/application.yml | |
sudo -u gitlab_ci -H editor config/application.yml | |
# Development | |
#sudo -u gitlab_ci -H cp config/application.yml.example.development config/application.yml | |
# Edit web server settings | |
sudo -u gitlab_ci -H cp config/unicorn.rb.example config/unicorn.rb | |
sudo -u gitlab_ci -H editor config/unicorn.rb | |
# Create socket and pid directories | |
sudo -u gitlab_ci -H mkdir -p tmp/sockets/ | |
sudo chmod -R u+rwX tmp/sockets/ | |
sudo -u gitlab_ci -H mkdir -p tmp/pids/ | |
sudo chmod -R u+rwX tmp/pids/ | |
### install gems | |
# for PostgreSQL (note, the option says "without ... mysql") | |
sudo -u gitlab_ci -H bundle install --without development test mysql --deployment | |
### database config | |
# postgres | |
sudo -u gitlab_ci -H cp config/database.yml.postgresql config/database.yml | |
# Setup tables | |
sudo -u gitlab_ci -H bundle exec rake setup RAILS_ENV=production | |
# Setup schedules | |
# | |
sudo -u gitlab_ci -H bundle exec whenever -w RAILS_ENV=production | |
# Copy the init script (will be /etc/init.d/gitlab_ci): | |
sudo cp /home/gitlab_ci/gitlab-ci/lib/support/init.d/gitlab_ci /etc/init.d/gitlab_ci | |
# Make GitLab start on boot: | |
sudo update-rc.d gitlab_ci defaults 21 | |
# Start your GitLab instance: | |
sudo service gitlab_ci start | |
# or | |
sudo /etc/init.d/gitlab_ci start | |
### give the permissions back to user gitlab_ci | |
chown -R gitlab_ci:gitlab_ci /home/gitlab_ci | |
### nginx config | |
cd /etc/nginx | |
mkdir sites-available sites-enabled | |
sudo wget https://raw.github.com/gitlabhq/gitlab-ci/2-2-stable/lib/support/nginx/gitlab_ci -P /etc/nginx/sites-available/ | |
sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci | |
vim /etc/nginx/sites-available/gitlab_ci | |
# - change the server_name of this server | |
# - dont forget delete default_server after `listen 80` | |
service nginx start | |
### disable user gitlab_ci login | |
usermod -s /sbin/nologin gitlab_ci | |
### make sure user `gitlab_ci` can execute commands by sudo without tty started | |
### because the init.d script needs `sudo -u gitlab_ci ...` to launch | |
### replace `Defaults requiretty` by this line in file `/etc/sudoers`: | |
### `Defaults:gitlab_ci !requiretty` | |
visudo | |
### done! | |
### use this account and password to login: | |
### [email protected] | |
### 5iveL!fe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment