Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
## Versão do OS 13.04 Server 64 Bits
## Disco de 30GB e 2GB de RAM
## Instalação limpa só com ssh e vi
## Vamos instalar com Mysql e Webserver Nginx
## Nesse Screencast não vou cobrir a instalação do Ubuntu pois é muito simples
## Versão que vai ser instalada é a 6.1 estavel do Gitlab
## Passo a passo de Instalação está nesse link
## https://github.com/gitlabhq/gitlabhq/blob/6-1-stable/doc/install/installation.md
## Vars
SERVER_IP="192.168.1.200"
SERVER_FQDN="gitlab.linuxpro.com.br"
DOMAIN="linuxpro.com.br"
MYSQL_PASS="123456"
## No change var
sudo_cmd="sudo -u git -H"
## Script de Instalação:
sudo apt-get install -y vim nginx python-pygments mysql-server mysql-client libmysqlclient-dev ruby-bundler
sudo apt-get install -y ruby ruby-dev build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev
sudo apt-get install -y libreadline-dev libncurses5-dev ruby-mysql2
sudo apt-get install -y libffi-dev curl git-core redis-server postfix checkinstall libxml2-dev
sudo apt-get install -y libxslt-dev libcurl4-openssl-dev libicu-dev wget
sudo update-alternatives --set editor /usr/bin/vim.basic
sudo gem install charlock_holmes --version '0.6.9.4'
sudo gem install bundler --no-ri --no-rdoc
sudo adduser --disabled-login --gecos 'GitLab' git
cd /home/git
$sudo_cmd git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
$sudo_cmd git checkout v1.7.1
$sudo_cmd cp config.yml.example config.yml
$sudo_cmd sed -i "s/localhost/$SERVER_FQDN/" /home/git/gitlab-shell/config.yml
$sudo_cmd ./bin/install
cd /home/git
$sudo_cmd git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
$sudo_cmd git checkout 6-1-stable
cd /home/git/gitlab
$sudo_cmd cp config/gitlab.yml.example config/gitlab.yml
$sudo_cmd sed -i "s/localhost/$SERVER_FQDN/" config/gitlab.yml
$sudo_cmd chown -R git log/
$sudo_cmd chown -R git tmp/
$sudo_cmd chmod -R u+rwX log/
$sudo_cmd chmod -R u+rwX tmp/
$sudo_cmd mkdir /home/git/gitlab-satellites
$sudo_cmd mkdir tmp/sockets
$sudo_cmd mkdir tmp/pids
$sudo_cmd chmod -R u+rwX tmp/pids/
$sudo_cmd chmod -R u+rwX tmp/sockets
# Create public/uploads directory otherwise backup will fail
$sudo_cmd mkdir public/uploads
$sudo_cmd chmod -R u+rwX public/uploads
$sudo_cmd cp config/unicorn.rb.example config/unicorn.rb
$sudo_cmd cp config/database.yml.mysql config/database.yml
$sudo_cmd sed -i 's/root/gitlab/' config/database.yml
$sudo_cmd sed -i 's/"secure password"/gitlab/' config/database.yml
echo 'CREATE USER gitlab@localhost IDENTIFIED BY "gitlab";
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO gitlab@localhost;'
| mysql -u root -p$MYSQL_PASS
cd /home/git/gitlab
$sudo_cmd bundle install --deployment --without development test postgres
$sudo_cmd bundle exec rake gitlab:setup RAILS_ENV=production
cd /home/git/gitlab
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
sudo chown -R git:git /home/git
cd /home/git/gitlab
$sudo_cmd git config --global user.name "GitLab"
$sudo_cmd git config --global user.email "gitlab@$DOMAIN"
$sudo_cmd bundle exec rake gitlab:env:info RAILS_ENV=production
$sudo_cmd bundle exec rake gitlab:check RAILS_ENV=production
sudo service gitlab start
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/$SERVER_IP/" /etc/nginx/sites-available/gitlab
sudo sed -i "s/YOUR_SERVER_FQDN/$SERVER_FQDN/" /etc/nginx/sites-available/gitlab
sudo service nginx restart
## Pronta a instalação foi finalizada, é só acessar o endereço:
## http://gitlab.linuxpro.com.br
## login: admin@local.host
## senha: 5iveL!fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment