Skip to content

Instantly share code, notes, and snippets.

@bastosmichael
Last active August 29, 2015 13:55
Show Gist options
  • Save bastosmichael/8739398 to your computer and use it in GitHub Desktop.
Save bastosmichael/8739398 to your computer and use it in GitHub Desktop.
Gitlab 6.5 Ubuntu Installer
#!/bin/bash
if [ $# -eq 0 ]
then
echo "gitlab.sh [options] postgres|mysql|restart
postgres - Automatically install gitlab with postgres on ubuntu
mysql - Automatically install gitlab with mysql on ubuntu (Not Finished)"
elif [ $1 == 'postgres' ]; 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 remove -y git-core
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:git-core/ppa
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 nginx python-docutils libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential git postgresql-9.1 postgresql-client libpq-dev
git --version
echo "Install Ruby 2.0..."
sudo apt-get remove -y ruby1.8 ruby1.9
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure --disable-install-rdoc
make
sudo make install
sudo gem install bundler --no-ri --no-rdoc
echo "Creating git user..."
sudo adduser --disabled-login --gecos 'GitLab' git
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}'
elif [ $1 == 'mysql' ]; 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..."
export $MYSQL_PASSWORD=
sudo apt-get remove -y git-core
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update -y
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password '
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '
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 nginx python-docutils libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential git mysql-server mysql-client libmysqlclient-dev
git --version
echo "Install Ruby 2.0..."
sudo apt-get remove -y ruby1.8 ruby1.9
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure --disable-install-rdoc
make
sudo make install
sudo gem install bundler --no-ri --no-rdoc
echo "Creating git user..."
sudo adduser --disabled-login --gecos 'GitLab' git
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 "Configuring MySQL..."
sudo mysql_secure_installation -y
# Login to MySQL
#mysql -u root -p
# Type the database root password
# Create a user for GitLab
# do not type the 'mysql>', this is part of the prompt
# change $password in the command below to a real password you pick
#mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
# Create the GitLab production database
#mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `u
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