Skip to content

adding install script for gitlab6.1 / ubuntu 12.04 / nginx #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions install/ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
One script installer for clean ubuntu 12.04 x64
==============

Made for GitLab v4.0
Made for GitLab v6.1

### ABOUT

This script performs a complete installation of Gitlab for ubuntu server 12.04.1 x64:
This script performs a complete installation of Gitlab for ubuntu server 12.04 LTS x64:
* packages update
* redis, git, postfix etc
* git, postfix etc
* ruby setup
* git, gitlab users
* gitolite fork
* git user
* gitlab-shell fork


### Notes
Expand Down
218 changes: 101 additions & 117 deletions install/ubuntu/ubuntu_server_1204.sh
Original file line number Diff line number Diff line change
@@ -1,196 +1,180 @@
#!/bin/sh

# GITLAB
# Maintainer: @randx
# App Version: 4.0
# By: steinkel at gmail.com
# App Version: 6.1 stable https://github.com/gitlabhq/gitlabhq/tree/6-1-stable

# ABOUT
# This script performs a complete installation of Gitlab for ubuntu server 12.04.1 x64:
# * packages update
# * redis, git, postfix etc
# * git, postfix etc
# * ruby setup
# * git, gitlab users
# * gitolite fork
# Is should be run as root or sudo user w/o password.
# * gitlab-shell fork
# Is should be run as root or sudo user w/o password.
#
# THANKS TO
# @randx for creating the original install script for gitlab 4
# https://www.digitalocean.com/community/articles/how-to-set-up-gitlab-as-your-very-own-private-github-clone
# https://gist.github.com/steinkel/5891151
#
# USAGE
# !IMPORTANT run as root or sudo without prompting password cause script ignore any input.
# curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/v4/ubuntu_server_1204.sh | sudo domain_var=gitlab.example.com sh
# sudo apt-get -y install curl && curl https://gist.github.com/steinkel/6855062/raw/1b738b5fab714b53bc37d12c428856a7b252ba39/ubuntu_server_1204.sh | sudo domain_var=gitlab.example.com sh
#


#==
#== 0. FQDN
#== 0. FQDN
#==

if [ $domain_var ] ; then
echo "Installing GitLab for domain: $domain_var"
else
echo "Please pass domain_var"
exit
echo "Installing GitLab for domain: $domain_var"
else
echo "Please pass domain_var"
exit
fi

echo "Host localhost
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config

echo "Host $domain_var
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config

StrictHostKeyChecking no
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config

#==
#== 1. Packages
#==
sudo apt-get update
sudo apt-get install -y wget curl build-essential checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev zlib1g-dev libicu-dev redis-server openssh-server git-core libyaml-dev


# Python

# Install Python
sudo apt-get install -y python

# Make sure that Python is 2.x (3.x is not supported at the moment)
python --version

# If it's Python 3 you might need to install Python 2 separately
sudo apt-get install python2.7

# Make sure you can access Python via python2
python2 --version

# If you get a "command not found" error create a link to the python binary
sudo ln -s /usr/bin/python /usr/bin/python2

# POSTFIX
sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python postfix # Install postfix without prompting.

sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev

#==
#== 2. RUBY
#==
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz
cd ruby-2.0.0-p247
./configure
make
sudo make install
sudo gem install bundler
sudo gem install bundler --no-ri --no-rdoc

# POSTFIX
# Install postfix without prompting.
sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python postfix

#==
#== 3. Users
#==
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git


sudo adduser --disabled-login --gecos 'GitLab' gitlab

# Add it to the git group
sudo usermod -a -G git gitlab

# Generate the SSH key
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
sudo adduser --disabled-login --gecos 'GitLab' git

#==
#== 4. Gitolite
#== 4. Gitlab Shell
#==

cd /home/git
sudo -u git -H git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
# Add Gitolite scripts to $PATH
sudo -u git -H mkdir /home/git/bin
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile'
sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'

# Copy the gitlab user's (public) SSH key ...
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub

# ... and use it as the admin key for the Gitolite setup
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"

sudo chmod -R ug+rwXs /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
# note, keep the gitlab shell updated here
sudo -u git -H git checkout v1.7.1
sudo -u git -H cp config.yml.example config.yml

sudo chmod 750 /home/git/.gitolite/
sudo chown -R git:git /home/git/.gitolite/


sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
sudo rm -rf /tmp/gitolite-admin
# setting up a default configuration
sudo sed -i s%localhost%$domain_var% config.yml

# run install script
sudo -u git -H ./bin/install

#==
#== 5. MySQL
#==
sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively.
userPassword=$(makepasswd --char=10) # Generate a random MySQL password
mysqlRootPassword=$(makepasswd --char=10) # Generate a random MySQL password
# Note that the lines below creates a cleartext copy of the random password in /var/cache/debconf/passwords.dat
# This file is normally only readable by root and the password will be deleted by the package management system after install.
echo mysql-server mysql-server/root_password password $userPassword | sudo debconf-set-selections
echo mysql-server mysql-server/root_password_again password $userPassword | sudo debconf-set-selections
echo mysql-server mysql-server/root_password password $mysqlRootPassword | sudo debconf-set-selections
echo mysql-server mysql-server/root_password_again password $mysqlRootPassword | sudo debconf-set-selections
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

# setting a gitlab user
gitlabPassword=$(makepasswd --char=10) # Generate a random MySQL password
queryCreateUser="CREATE USER gitlab@localhost IDENTIFIED BY '$gitlabPassword';"
queryCreateDb="CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
queryGrant="GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO gitlab@localhost;"
queryGitlabDb="${queryCreateUser} ${queryCreateDb} ${queryGrant}"
mysql -uroot -p$mysqlRootPassword -e "$queryGitlabDb"

#==
#== 6. GitLab
#==
cd /home/gitlab
sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/gitlab/gitlab
# Checkout v4
sudo -u gitlab -H git checkout 4-0-stable
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
sudo -u git -H git checkout 6-1-stable

# Copy the example GitLab config
sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u gitlab -H cp config/database.yml.mysql config/database.yml
sudo sed -i 's/"secure password"/"'$userPassword'"/' /home/gitlab/gitlab/config/database.yml # Insert the mysql root password.
sudo sed -i "s/ host: localhost/ host: $domain_var/" /home/gitlab/gitlab/config/gitlab.yml
sudo sed -i "s/ssh_host: localhost/ssh_host: $domain_var/" /home/gitlab/gitlab/config/gitlab.yml
sudo sed -i "s/notify@localhost/notify@$domain_var/" /home/gitlab/gitlab/config/gitlab.yml
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H cp config/database.yml.mysql config/database.yml
sudo sed -i 's/root/gitlab/' config/database.yml # Insert the mysql root password.
sudo sed -i 's/"secure password"/"'$gitlabPassword'"/' config/database.yml # Insert the mysql root password.
sudo sed -i "s/ host: localhost/ host: $domain_var/" config/gitlab.yml
sudo sed -i "s/ssh_host: localhost/ssh_host: $domain_var/" config/gitlab.yml
sudo sed -i "s/notify@localhost/notify@$domain_var/" config/gitlab.yml

# Set some permissions
cd /home/git/gitlab
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX public/uploads
sudo -u git -H chmod o-rwx config/database.yml

# Setup default git parameters
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@$domain_var"
sudo -u git -H git config --global core.autocrlf input

# Copy the example Unicorn config
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb

cd /home/gitlab/gitlab
# Setup additional gems
cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9.4'
sudo -u git -H bundle install --deployment --without development test postgres aws

sudo gem install charlock_holmes --version '0.6.9'
sudo -u gitlab -H bundle install --deployment --without development postgres test
# force rake setup, will overwrite database gitlabhq_production
echo "yes" | sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"

sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive

sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production

sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/4-0-stable/init.d/gitlab -P /etc/init.d/
# Setup gitlab autorun script
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab

sudo update-rc.d gitlab defaults 21


#==
#== 7. Nginx
#==
sudo apt-get install -y nginx
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/4-0-stable/nginx/gitlab -P /etc/nginx/sites-available/
sudo apt-get -y install nginx
cd /home/git/gitlab
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab


sudo sed -i 's/YOUR_SERVER_IP:80/80/' /etc/nginx/sites-available/gitlab # Set Domain
sudo sed -i "s/YOUR_SERVER_FQDN/$domain_var/" /etc/nginx/sites-available/gitlab

# Start all

sudo service gitlab start
sudo service nginx start

# Show info details
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

echo "IMPORTANT: Mysql root password is $mysqlRootPassword"
echo "Gitlab user is [email protected]"
echo "Gitlab password is 5iveL!fe"
echo "EOT"