Last active
August 29, 2015 14:03
-
-
Save bastosmichael/ca6830a62b2730f1dfff to your computer and use it in GitHub Desktop.
Gitlab 7.0 Ubuntu 14.04 Postgres Install
This file contains hidden or 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/bash | |
if [ $# -eq 0 ] | |
then | |
echo "gitlab.sh [options] install | |
elif [ $1 == 'install' ]; then | |
echo "Updating Operating System..." | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
echo "Switching to VIM..." | |
sudo apt-get install -y vim | |
sudo update-alternatives --set editor /usr/bin/vim.basic | |
echo "Installing Dependencies..." | |
sudo apt-get install -y python-software-properties | |
sudo apt-get update -y | |
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils nginx libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev git postgresql-9.3 postgresql-client libpq-dev | |
git --version | |
echo "Creating git user..." | |
sudo adduser --disabled-login --gecos 'GitLab' git | |
echo "Install Ruby 2.1.2..." | |
sudo apt-get remove -y ruby1.8 ruby1.9 | |
sudo apt-get update -y | |
sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties | |
sudo -u git -H curl -L https://get.rvm.io | bash -s stable | |
sudo -u git -H source ~/.rvm/scripts/rvm | |
sudo -u git -H echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc | |
sudo -u git -H rvm install 2.1.2 | |
sudo -u git -H rvm use 2.1.2 --default | |
sudo -u git -H ruby -v | |
sudo gem install bundler --no-ri --no-rdoc | |
echo "Installing gitlab-shell..." | |
cd /home/git | |
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0 | |
cd gitlab-shell | |
sudo -u git -H cp config.yml.example config.yml | |
export IP=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` | |
sudo -u git -H sed -ri "/localhost/c\gitlab_url: \"http://$IP/\"" config.yml | |
sudo -u git -H ./bin/install | |
echo "Installing Gitlab..." | |
cd /home/git | |
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-5-stable gitlab | |
cd /home/git/gitlab | |
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml | |
sudo -u git -H sed -ri "/host: localhost/c\ host: $IP" config/gitlab.yml | |
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 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 git config --global user.name "GitLab" | |
sudo -u git -H git config --global user.email "gitlab@localhost" | |
sudo -u git -H git config --global core.autocrlf input | |
echo "Configuring Postgres..." | |
sudo -u postgres psql -c "CREATE USER git;" | |
sudo -u postgres psql -c "CREATE DATABASE gitlabhq_production OWNER git;" | |
sudo -u git cp config/database.yml.postgresql config/database.yml | |
sudo -u git -H chmod o-rwx config/database.yml | |
echo "Configuring Gitlab..." | |
sudo -u git -H bundle install --deployment --without development test mysql aws | |
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production | |
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab | |
sudo update-rc.d gitlab defaults 21 | |
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab | |
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production | |
sudo service gitlab start | |
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production | |
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 -ri "/YOUR_SERVER_FQDN/c\ server_name $IP;" /etc/nginx/sites-enabled/gitlab | |
sudo service nginx restart | |
echo "Check if Gitlab fully installed..." | |
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production | |
echo "Done. Visit the below address with username: [email protected] and password: 5iveL!fe" | |
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print "http://" $1}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment