Last active
August 29, 2015 13:56
-
-
Save amercier/9187946 to your computer and use it in GitHub Desktop.
bash <(curl -# https://gist.githubusercontent.com/amercier/9187946/raw) <hostname> <mysql_password>
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
#!/usr/bin/env bash | |
if [ "`whoami`" != "root" ]; then | |
echo "You must execute this script as root" >&2 | |
exit 1 | |
fi | |
echo ".---------------------." | |
echo "| GitLab installation |" | |
echo "'---------------------'" | |
hostname=$1 | |
mysql_password=$2 | |
aptitude install -y mysql-server mysql-client libmysqlclient-dev \ | |
&& mysql -u root -p$mysql_password -e 'SHOW DATABASES' || exit 1 | |
cd \ | |
\ | |
&& aptitude update \ | |
&& aptitude upgrade \ | |
\ | |
&& aptitude install 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 \ | |
\ | |
&& aptitude install python python-docutils \ | |
&& python --version \ | |
\ | |
&& aptitude install git-core \ | |
&& git --version \ | |
\ | |
&& aptitude install postfix \ | |
\ | |
&& aptitude remove ruby1.8 \ | |
&& bash <(curl -# https://gist.githubusercontent.com/amercier/8461147/raw) \ | |
&& gem install bundler --no-ri --no-rdoc \ | |
\ | |
&& adduser --disabled-login --gecos 'GitLab' git \ | |
\ | |
&& 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 \ | |
&& sed -i -e "s/localhost/$hostname/g" config.yml \ | |
&& sudo -u git -H ./bin/install \ | |
\ | |
&& mysql_secure_installation \ | |
&& mysql -u root -p$mysql_password -e "CREATE USER 'git'@'localhost' IDENTIFIED BY '$mysql_password'" \ | |
&& mysql -u root -p$mysql_password -e "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;" \ | |
&& mysql -u root -p$mysql_password -e "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO git@localhost;" \ | |
&& sudo -u git -H mysql -u git -p$mysql_password -D gitlabhq_production -e 'SHOW DATABASES' \ | |
\ | |
&& 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 \ | |
&& sed -i -e "s/localhost/$hostname/g" config/gitlab.yml \ | |
&& sed -i -e "s/timeout 30/timeout 300/g" config/unicorn.rb \ | |
&& 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@$hostname" \ | |
&& sudo -u git -H git config --global core.autocrlf input \ | |
&& sudo -u git cp config/database.yml.mysql config/database.yml \ | |
&& sed -i -e "s/secure password/$mysql_password/g" config/database.yml \ | |
&& sudo -u git -H chmod o-rwx config/database.yml \ | |
&& sudo -u git -H bundle install --deployment --without development test postgres aws \ | |
&& sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production \ | |
&& cp lib/support/init.d/gitlab /etc/init.d/gitlab \ | |
&& update-rc.d gitlab defaults 21 \ | |
&& cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab \ | |
&& sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production \ | |
&& service gitlab start \ | |
&& sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production \ | |
\ | |
&& aptitude install -y nginx \ | |
&& cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab \ | |
&& ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab \ | |
&& sed -i -e "s/YOUR_SERVER_FQDN/$hostname/g" /etc/nginx/sites-enabled/gitlab \ | |
&& sed -i -e "s/client_max_body_size 5m/client_max_body_size 200m/g" /etc/nginx/sites-enabled/gitlab \ | |
&& service nginx restart \ | |
&& sed -i -e "s/localhost\$/localhost $hostname/" /etc/hosts \ | |
&& sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production \ | |
\ | |
&& echo ".---------------------------------------." \ | |
&& echo "| GitLab installed successfully |" \ | |
&& echo '| Log in with [email protected]/5iveL!fe |' \ | |
&& echo "'---------------------------------------'" \ | |
&& echo -n 'GitLab v' \ | |
&& cd /home/git/gitlab \ | |
&& git branch | sed -e 's/.*\([0-9]\)-\([0-9]\).*/\1.\2/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment