From 2b64ff640da6a31a07004a0fdcb310ddeda79825 Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Mon, 30 Sep 2013 11:28:19 -0400 Subject: [PATCH] add debian/ubuntu igitlab installer --- install/debian/README.md | 66 +++++ install/debian/igitlab | 411 +++++++++++++++++++++++++++ install/ubuntu/README.md | 71 +++-- install/ubuntu/igitlab | 411 +++++++++++++++++++++++++++ install/ubuntu/ubuntu_server_1204.sh | 196 ------------- 5 files changed, 943 insertions(+), 212 deletions(-) create mode 100644 install/debian/igitlab create mode 100644 install/ubuntu/igitlab delete mode 100644 install/ubuntu/ubuntu_server_1204.sh diff --git a/install/debian/README.md b/install/debian/README.md index e69de29..43a82a1 100644 --- a/install/debian/README.md +++ b/install/debian/README.md @@ -0,0 +1,66 @@ + iii GGGG iii tt LL bb + GG GG tt LL aa aa bb + iii GG iii tttt LL aa aaa bbbbbb + iii GG GG iii tt LL aa aaa bb bb + iii GGGGGG iii tttt LLLLLLL aaa aa bbbbbb + +# iGitLab - GitLab Ubuntu/Debian Installer Bash/Shell Script +http://smyl.es/igitlab-configurable-gitlab-multi-version-bashshell-installer-script-for-debian-ubuntu-linux-mint-etc/ + +Name says it all, use this script to install GitLab on any debian flavored server, check the script for configuration options. + +Tested working on 6-1-stable, but should work on other versions and master as well. Change "master" below in wget to 6-1-stable if you want to use that branch. + +## Installation +``` bash +wget https://raw.github.com/tripflex/igitlab/master/igitlab +chmod +x igitlab +``` + +## Usage +``` bash +./igitlab mygitdomain.com +``` + +## Configuration Options + +### GitLab Release +Set this to whatever branch you want to use for the GitLab installation. Current tested working version is 6-1-stable, change to master for latest. +``` bash +gitlab_release=6-1-stable +``` + +### Unicorn or Puma +Version 5.1 through 5.9 uses Puma, whereas 6.0 will start using Unicorn again. Set this to 1 if you are installing a version that requires Unicorn instead of Puma. +``` bash +useunicorn=1 +``` + +### Ruby Download URL +Set this to the URL to download Ruby source +``` bash +rubydlurl="ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" +``` + +### MySQL Root Password +Set this to the root password for MySQL access. If MySQL is not setup yet on the server you will be prompted to set one up, and then enter it again for the script to use. You will probably only need to set this if you already have MySQL setup, or just enter it when script asks for it. +``` bash +mysqlpasswd="" +``` + +### Apt Arguments +Set this to the arguments you want ran with apt when updating, and installing. Current default is set to "-qq" which assumes -y and supresses output from apt. Set to -y for standard output. +``` bash +# -s = simulate +# -y = yes (no prompt) +# -q = quiet +# -qq = even more quiet (also implies -y, do not use with -s) +aptget_arguments="-qq" +``` + +### Apt Log Files +Set these to filenames you want to use for apt logs +``` bash +APTLOG=apt.log +APTERRLOG=apterror.log +``` diff --git a/install/debian/igitlab b/install/debian/igitlab new file mode 100644 index 0000000..f8626b7 --- /dev/null +++ b/install/debian/igitlab @@ -0,0 +1,411 @@ +#!/bin/bash +igitlab() { + cat <<"EOT" + 88 ,ad8888ba, 88 88 88 + "" d8"' `"8b "" ,d 88 88 + d8' 88 88 88 + 88 88 88 MM88MMM 88 ,adPPYYba, 88,dPPYba, + 88 88 88888 88 88 88 "" `Y8 88P' "8a + 88 Y8, 88 88 88 88 ,adPPPPP88 88 d8 + 88 Y8a. .a88 88 88, 88 88, ,88 88b, ,a8" + 88 Y88888P 88 "Y888 88888888888 `"8bbdP"Y8 8Y"Ybbd8"' + +EOT +} +# +# Ubuntu/Debian Installer +# ------------------------------------------------------------------------------ +# @author Myles McNamara +# @date 9.26.2013 +# @version 1.1 +# @source https://github.com/tripflex/igitlab +# ------------------------------------------------------------------------------ +# @usage ./igetlab domain.com +# ------------------------------------------------------------------------------ +# @copyright Copyright (C) 2013 Myles McNamara +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------------ + +# ============================================================================= +# = Required Script Configuration Values = +# ============================================================================= +# -------------------------------------------------------- +# - GitHub branch to use. Use master for latest release - +# -------------------------------------------------------- +# For versions <=5.0 or >=6.0 the Unicorn Gem is used, 5.1-5.9 uses Puma, if you used master Unicorn is required. + gitlab_release=6-1-stable +# ------------------------------------------------------- +# - Unicorn or Puma, Puma default, set to 1 for Unicorn - +# ------------------------------------------------------- + useunicorn=1 +# -------------------------------------- +# - Version of GitLab Shell to install - +# -------------------------------------- + gitlab-shell_release=v1.7.1 +# ------------------------------------- +# - Download URL for Ruby tar.gz file - +# ------------------------------------- +# We will use Ruby 2 for >6 + rubydlurl="ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" +# rubydlurl="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz" +# -------------------------------------------------- +# - MySQL Root Password, will prompt if left blank - +# -------------------------------------------------- + mysqlpasswd="" +# ------------------------------ +# - Optional apt-get arguments - +# ------------------------------ +# -s = simulate +# -y = yes (no prompt) +# -q = quiet +# -qq = even more quiet (also implies -y, do not use with -s) +# ------------------------------ + aptget_arguments="-qq" + APTLOG=apt.log + APTERRLOG=apterror.log + +########################### +# That's far enough buddy # +########################### + +# ============= +# = Functions = +# ============= + +function givemeayes { + echo -n "$1 " + read answer + case "$answer" in + Y|y|yes|YES|Yes) return 0 ;; + *) echo -e "\nCaptain, we hit the eject button!\n"; exit ;; + esac +} +function info { + echo -e "\n--INFO-- $1" +} +function debug { + echo -e "\n--DEBUG-- $1" +} +function msg { + echo "$1" +} +function msgnl { + echo -e "\n$1" +} +function mybanner { + l=${#1} + printf "%s\n%s\n%s\n" "--${1//?/-}--" "- $1 -" "--${1//?/-}--" +} +# ====================== +# = General Start Code = +# ====================== + +if [[ "$1" = "-h" || "$1" = "--help" || $1 == -* ]]; then + echo "Usage: $0 domain.com" >&2 + exit +fi + +clear + +# Output Logo +igitlab + +# Check for domain +if [ "$#" -lt 1 ]; then + msg "Domain was not specified, using localhost as default!" + domain_var=localhost +else + domain_var=$1 +fi + +# Check for MySQL root password +if [ -z "$mysqlpasswd" ]; then + msg "MySQL root password not set in configuration." +fi + +mybanner "GitLab Installation Details" +msg "Domain: $domain_var" +msg "Version: $gitlab_release" +msg "Ruby URL: $rubydlurl" +msg "Unicorn: $useunicorn" +msg "--------------------------------" +givemeayes "Would you like to continue with the install? (y/n)" + +# ==================== +# = Install Packages = +# ==================== +# +msgnl "[iGitLab] Updating package information..." +sudo apt-get update $aptget_arguments +msgnl "Installing required packages, please wait this could take a minute..." +sudo apt-get install $aptget_arguments build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl wget git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev 1>>$APTLOG 2>>$APTERRLOG || (echo "apt-get install failed, check APTLOG and APTERRLOG" ; exit) + +# ====================== +# = MySQL Installation = +# ====================== +# + +# Install the database packages +sudo apt-get install $aptget_arguments mysql-server mysql-client libmysqlclient-dev + +# Check for MySQL root password +if [ -z "$mysqlpasswd" ]; then + echo -e "\n[iGitLab] MySQL root password not provided, please enter the password you used now." + read mysqlpasswd + if [ -z "$mysqlpasswd" ]; then + echo -e "\n[iGitLab] MySQL root password not provided, exiting installer, please run again after you set the root password." + exit 0 + fi +fi + +# Generate a random gitlab MySQL password +gitlabpass=$(openssl rand -base64 12) + +if [ -z "$gitlabpass" ]; then + echo -e "\n[iGitLab] Random password generation failed, please enter a password to use for GitLab MySQL user:" + read gitlabpass +fi + +# Create a user for GitLab. +mysql -uroot -p$mysqlpasswd -e "CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$gitlabpass';" + +# Create the GitLab production database +mysql -uroot -p$mysqlpasswd -e "CREATE DATABASE IF NOT EXISTS \`gitlabhq_production\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;" + +# Grant the GitLab user necessary permissons on the table. +mysql -uroot -p$mysqlpasswd -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`gitlabhq_production\`.* TO 'gitlab'@'localhost';" + +# Quit the database session +mysql -uroot -p$mysqlpasswd -e "\\q;" + +# Try connecting to the new database with the new user +# sudo -u git -H mysql -ugitlab -p$gitlabpass -D gitlabhq_production + +# ======================= +# = Python Installation = +# ======================= +# +echo -e "\n[iGitLab] Installing Python..." +sudo apt-get install $aptget_arguments 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 $aptget_arguments python2.7 python-docutils + +# 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 Install = +# =================== +# +sudo DEBIAN_FRONTEND='noninteractive' apt-get install $aptget_arguments postfix-policyd-spf-python postfix # Install postfix without prompting. + +# ===================== +# = Ruby Installation = +# ===================== +# +# Remove Ruby1.8 if installed +echo -e "\n[iGitLab] Removing Ruby1.8 if installed..." +sudo apt-get remove $aptget_arguments ruby1.8 +echo -e "\n[iGitLab] Downloading $rubydlurl..." +curl --progress-bar $rubydlurl | tar xz +cd ruby-* +echo -e "\n[iGitLab] Configuring Ruby..." +./configure --silent +echo -e "\n[iGitLab] Making Ruby..." +make --silent +echo -e "\n[iGitLab] Installing Ruby..." +sudo make install --silent + +# Bundler Gem (-q for quiet) +echo -e "\n[iGitLab] Installing Bundler Gem..." +sudo gem install bundler --no-ri --no-rdoc -q + +# ================ +# = System Users = +# ================ +# +# Create system git user for GitLab +echo -e "\n[iGitLab] Creating system git user for GitLab..." +sudo adduser --disabled-login --gecos 'GitLab' git + +# ============================= +# = GitLab Shell Installation = +# ============================= +# +# Go to home directory +cd /home/git + +# Clone gitlab shell +sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git +cd gitlab-shell +# switch to right version +sudo -u git -H git checkout $gitlab-shell_release +# copy example config to config.yml +sudo -u git -H cp config.yml.example config.yml + +# Edit config and replace gitlab_url +sudo -u git -H sed -i "s/localhost/${domain_var}/g" config.yml + +# Do setup +sudo -u git -H ./bin/install + +# ======================= +# = GitLab Installation = +# ======================= +# +cd /home/git +# Clone GitLab repository +sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab + +# Go to gitlab dir +cd /home/git/gitlab + +# Checkout to release +sudo -u git -H git checkout $gitlab_release + +# ======================== +# = GitLab Configuration = +# ======================== +# +cd /home/git/gitlab + +# Copy the example GitLab config +sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml + +# Replace localhost with domain +sudo -u git -H sed -i "s/localhost/${domain_var}/g" config/gitlab.yml + +# Make sure GitLab can write to the log/ and tmp/ directories +sudo chown -R git log/ +sudo chown -R git tmp/ +sudo chmod -R u+rwX log/ +sudo chmod -R u+rwX tmp/ + +# Create directory for satellites +sudo -u git -H mkdir /home/git/gitlab-satellites + +# Create directories for sockets/pids and make sure GitLab can write to them +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/ + +# Create public/uploads directory otherwise backup will fail +sudo -u git -H mkdir public/uploads +sudo chmod -R u+rwX public/uploads + +# Copy the example Unicorn config (Version < 5.1 use Unicorn, versions > 5.1 use Puma) +# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb + +# Copy the example of Puma config + +if [ "$useunicorn" -eq 1 ]; then + sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb + pumaorunicorn="puma" +else + sudo -u git -H cp config/puma.rb.example config/puma.rb + pumaorunicorn="unicorn" +fi + +# Configure Git global settings for git user +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 + +# ================================= +# = GitLab Database Configuration = +# ================================= + +# Mysql +sudo -u git cp config/database.yml.mysql config/database.yml + +# Insert database password into config +passwdph="secure password" +sed -i "s/${passwdph}/${gitlabpass}/g" config/database.yml + +# Replace MySQL user root with gitlab +sed -i 's/root/gitlab/g' config/database.yml + +# Make config/database.yml readable to git only +sudo -u git -H chmod o-rwx config/database.yml + +# ======================= +# = GitLab Gems Install = +# ======================= +# +cd /home/git/gitlab + +sudo gem install charlock_holmes --version '0.6.9.4' + +# For MySQL (note, the option says "without ... postgres") +sudo -u git -H bundle install --deployment --without development test postgres aws + + +# ================================================ +# = Initialize DB and Activate Advanced Features = +# ================================================ +sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production + +# ====================== +# = GitLab Init Script = +# ====================== +# +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab + +# Set GitLab to start on boot +sudo update-rc.d gitlab defaults 21 + +# =================== +# = Apache Handling = +# =================== +# +if [ -f /etc/init.d/apache2 ]; then + echo -e "\n[iGitLab] Apache init found, attempting to stop" + sudo /etc/init.d/apache2 stop + echo -e "\n[iGitLab] Disabling apache from starting at boot" + sudo update-rc.d apache2 remove +fi + +# ================= +# = Install Nginx = +# ================= +echo -e "\n[iGitLab] Attempting to install Nginx ..." +sudo apt-get install $aptget_arguments nginx +sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab +sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab + +# 5-3-stable and prior has YOUR_SERVER_IP in nginx conf, post 5-3-stable does not +sudo sed -i 's/YOUR_SERVER_IP:80/*:80/g' /etc/nginx/sites-available/gitlab + +# Replace YOUR_SERVER_FQDN with domain +sudo sed -i "s/YOUR_SERVER_FQDN/${domain_var}/g" /etc/nginx/sites-available/gitlab + +# =========================== +# = Where the magic happens = +# =========================== +sudo service gitlab start +sudo service nginx start + +echo "Install Complete." +echo -e "\n------------------------------------------------------------" +echo -e "\n[iGitLab] You can login at $domain_var" +echo -e "\n[iGitLab] Username: admin@local.host" +echo -e "\n[iGitLab] Password: 5iveL!fe" +echo -e "\n------------------------------------------------------------" diff --git a/install/ubuntu/README.md b/install/ubuntu/README.md index dcd53f2..43a82a1 100644 --- a/install/ubuntu/README.md +++ b/install/ubuntu/README.md @@ -1,27 +1,66 @@ -One script installer for clean ubuntu 12.04 x64 -============== + iii GGGG iii tt LL bb + GG GG tt LL aa aa bb + iii GG iii tttt LL aa aaa bbbbbb + iii GG GG iii tt LL aa aaa bb bb + iii GGGGGG iii tttt LLLLLLL aaa aa bbbbbb + +# iGitLab - GitLab Ubuntu/Debian Installer Bash/Shell Script +http://smyl.es/igitlab-configurable-gitlab-multi-version-bashshell-installer-script-for-debian-ubuntu-linux-mint-etc/ -Made for GitLab v4.0 +Name says it all, use this script to install GitLab on any debian flavored server, check the script for configuration options. -### ABOUT +Tested working on 6-1-stable, but should work on other versions and master as well. Change "master" below in wget to 6-1-stable if you want to use that branch. -This script performs a complete installation of Gitlab for ubuntu server 12.04.1 x64: -* packages update -* redis, git, postfix etc -* ruby setup -* git, gitlab users -* gitolite fork +## Installation +``` bash +wget https://raw.github.com/tripflex/igitlab/master/igitlab +chmod +x igitlab +``` +## Usage +``` bash +./igitlab mygitdomain.com +``` -### Notes +## Configuration Options -__!IMPORTANT run as root or sudo without prompting password cause script ignore any input.__ +### GitLab Release +Set this to whatever branch you want to use for the GitLab installation. Current tested working version is 6-1-stable, change to master for latest. +``` bash +gitlab_release=6-1-stable +``` +### Unicorn or Puma +Version 5.1 through 5.9 uses Puma, whereas 6.0 will start using Unicorn again. Set this to 1 if you are installing a version that requires Unicorn instead of Puma. +``` bash +useunicorn=1 +``` -### USAGE +### Ruby Download URL +Set this to the URL to download Ruby source +``` bash +rubydlurl="ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" +``` -#### 1. Run script (replace gitlab.example.com with your domain or ip address) +### MySQL Root Password +Set this to the root password for MySQL access. If MySQL is not setup yet on the server you will be prompted to set one up, and then enter it again for the script to use. You will probably only need to set this if you already have MySQL setup, or just enter it when script asks for it. +``` bash +mysqlpasswd="" +``` - curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/ubuntu/ubuntu_server_1204.sh | sudo domain_var=gitlab.example.com sh +### Apt Arguments +Set this to the arguments you want ran with apt when updating, and installing. Current default is set to "-qq" which assumes -y and supresses output from apt. Set to -y for standard output. +``` bash +# -s = simulate +# -y = yes (no prompt) +# -q = quiet +# -qq = even more quiet (also implies -y, do not use with -s) +aptget_arguments="-qq" +``` -#### 2. Reboot machine +### Apt Log Files +Set these to filenames you want to use for apt logs +``` bash +APTLOG=apt.log +APTERRLOG=apterror.log +``` diff --git a/install/ubuntu/igitlab b/install/ubuntu/igitlab new file mode 100644 index 0000000..f8626b7 --- /dev/null +++ b/install/ubuntu/igitlab @@ -0,0 +1,411 @@ +#!/bin/bash +igitlab() { + cat <<"EOT" + 88 ,ad8888ba, 88 88 88 + "" d8"' `"8b "" ,d 88 88 + d8' 88 88 88 + 88 88 88 MM88MMM 88 ,adPPYYba, 88,dPPYba, + 88 88 88888 88 88 88 "" `Y8 88P' "8a + 88 Y8, 88 88 88 88 ,adPPPPP88 88 d8 + 88 Y8a. .a88 88 88, 88 88, ,88 88b, ,a8" + 88 Y88888P 88 "Y888 88888888888 `"8bbdP"Y8 8Y"Ybbd8"' + +EOT +} +# +# Ubuntu/Debian Installer +# ------------------------------------------------------------------------------ +# @author Myles McNamara +# @date 9.26.2013 +# @version 1.1 +# @source https://github.com/tripflex/igitlab +# ------------------------------------------------------------------------------ +# @usage ./igetlab domain.com +# ------------------------------------------------------------------------------ +# @copyright Copyright (C) 2013 Myles McNamara +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# ------------------------------------------------------------------------------ + +# ============================================================================= +# = Required Script Configuration Values = +# ============================================================================= +# -------------------------------------------------------- +# - GitHub branch to use. Use master for latest release - +# -------------------------------------------------------- +# For versions <=5.0 or >=6.0 the Unicorn Gem is used, 5.1-5.9 uses Puma, if you used master Unicorn is required. + gitlab_release=6-1-stable +# ------------------------------------------------------- +# - Unicorn or Puma, Puma default, set to 1 for Unicorn - +# ------------------------------------------------------- + useunicorn=1 +# -------------------------------------- +# - Version of GitLab Shell to install - +# -------------------------------------- + gitlab-shell_release=v1.7.1 +# ------------------------------------- +# - Download URL for Ruby tar.gz file - +# ------------------------------------- +# We will use Ruby 2 for >6 + rubydlurl="ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" +# rubydlurl="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz" +# -------------------------------------------------- +# - MySQL Root Password, will prompt if left blank - +# -------------------------------------------------- + mysqlpasswd="" +# ------------------------------ +# - Optional apt-get arguments - +# ------------------------------ +# -s = simulate +# -y = yes (no prompt) +# -q = quiet +# -qq = even more quiet (also implies -y, do not use with -s) +# ------------------------------ + aptget_arguments="-qq" + APTLOG=apt.log + APTERRLOG=apterror.log + +########################### +# That's far enough buddy # +########################### + +# ============= +# = Functions = +# ============= + +function givemeayes { + echo -n "$1 " + read answer + case "$answer" in + Y|y|yes|YES|Yes) return 0 ;; + *) echo -e "\nCaptain, we hit the eject button!\n"; exit ;; + esac +} +function info { + echo -e "\n--INFO-- $1" +} +function debug { + echo -e "\n--DEBUG-- $1" +} +function msg { + echo "$1" +} +function msgnl { + echo -e "\n$1" +} +function mybanner { + l=${#1} + printf "%s\n%s\n%s\n" "--${1//?/-}--" "- $1 -" "--${1//?/-}--" +} +# ====================== +# = General Start Code = +# ====================== + +if [[ "$1" = "-h" || "$1" = "--help" || $1 == -* ]]; then + echo "Usage: $0 domain.com" >&2 + exit +fi + +clear + +# Output Logo +igitlab + +# Check for domain +if [ "$#" -lt 1 ]; then + msg "Domain was not specified, using localhost as default!" + domain_var=localhost +else + domain_var=$1 +fi + +# Check for MySQL root password +if [ -z "$mysqlpasswd" ]; then + msg "MySQL root password not set in configuration." +fi + +mybanner "GitLab Installation Details" +msg "Domain: $domain_var" +msg "Version: $gitlab_release" +msg "Ruby URL: $rubydlurl" +msg "Unicorn: $useunicorn" +msg "--------------------------------" +givemeayes "Would you like to continue with the install? (y/n)" + +# ==================== +# = Install Packages = +# ==================== +# +msgnl "[iGitLab] Updating package information..." +sudo apt-get update $aptget_arguments +msgnl "Installing required packages, please wait this could take a minute..." +sudo apt-get install $aptget_arguments build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl wget git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev 1>>$APTLOG 2>>$APTERRLOG || (echo "apt-get install failed, check APTLOG and APTERRLOG" ; exit) + +# ====================== +# = MySQL Installation = +# ====================== +# + +# Install the database packages +sudo apt-get install $aptget_arguments mysql-server mysql-client libmysqlclient-dev + +# Check for MySQL root password +if [ -z "$mysqlpasswd" ]; then + echo -e "\n[iGitLab] MySQL root password not provided, please enter the password you used now." + read mysqlpasswd + if [ -z "$mysqlpasswd" ]; then + echo -e "\n[iGitLab] MySQL root password not provided, exiting installer, please run again after you set the root password." + exit 0 + fi +fi + +# Generate a random gitlab MySQL password +gitlabpass=$(openssl rand -base64 12) + +if [ -z "$gitlabpass" ]; then + echo -e "\n[iGitLab] Random password generation failed, please enter a password to use for GitLab MySQL user:" + read gitlabpass +fi + +# Create a user for GitLab. +mysql -uroot -p$mysqlpasswd -e "CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$gitlabpass';" + +# Create the GitLab production database +mysql -uroot -p$mysqlpasswd -e "CREATE DATABASE IF NOT EXISTS \`gitlabhq_production\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;" + +# Grant the GitLab user necessary permissons on the table. +mysql -uroot -p$mysqlpasswd -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`gitlabhq_production\`.* TO 'gitlab'@'localhost';" + +# Quit the database session +mysql -uroot -p$mysqlpasswd -e "\\q;" + +# Try connecting to the new database with the new user +# sudo -u git -H mysql -ugitlab -p$gitlabpass -D gitlabhq_production + +# ======================= +# = Python Installation = +# ======================= +# +echo -e "\n[iGitLab] Installing Python..." +sudo apt-get install $aptget_arguments 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 $aptget_arguments python2.7 python-docutils + +# 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 Install = +# =================== +# +sudo DEBIAN_FRONTEND='noninteractive' apt-get install $aptget_arguments postfix-policyd-spf-python postfix # Install postfix without prompting. + +# ===================== +# = Ruby Installation = +# ===================== +# +# Remove Ruby1.8 if installed +echo -e "\n[iGitLab] Removing Ruby1.8 if installed..." +sudo apt-get remove $aptget_arguments ruby1.8 +echo -e "\n[iGitLab] Downloading $rubydlurl..." +curl --progress-bar $rubydlurl | tar xz +cd ruby-* +echo -e "\n[iGitLab] Configuring Ruby..." +./configure --silent +echo -e "\n[iGitLab] Making Ruby..." +make --silent +echo -e "\n[iGitLab] Installing Ruby..." +sudo make install --silent + +# Bundler Gem (-q for quiet) +echo -e "\n[iGitLab] Installing Bundler Gem..." +sudo gem install bundler --no-ri --no-rdoc -q + +# ================ +# = System Users = +# ================ +# +# Create system git user for GitLab +echo -e "\n[iGitLab] Creating system git user for GitLab..." +sudo adduser --disabled-login --gecos 'GitLab' git + +# ============================= +# = GitLab Shell Installation = +# ============================= +# +# Go to home directory +cd /home/git + +# Clone gitlab shell +sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git +cd gitlab-shell +# switch to right version +sudo -u git -H git checkout $gitlab-shell_release +# copy example config to config.yml +sudo -u git -H cp config.yml.example config.yml + +# Edit config and replace gitlab_url +sudo -u git -H sed -i "s/localhost/${domain_var}/g" config.yml + +# Do setup +sudo -u git -H ./bin/install + +# ======================= +# = GitLab Installation = +# ======================= +# +cd /home/git +# Clone GitLab repository +sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab + +# Go to gitlab dir +cd /home/git/gitlab + +# Checkout to release +sudo -u git -H git checkout $gitlab_release + +# ======================== +# = GitLab Configuration = +# ======================== +# +cd /home/git/gitlab + +# Copy the example GitLab config +sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml + +# Replace localhost with domain +sudo -u git -H sed -i "s/localhost/${domain_var}/g" config/gitlab.yml + +# Make sure GitLab can write to the log/ and tmp/ directories +sudo chown -R git log/ +sudo chown -R git tmp/ +sudo chmod -R u+rwX log/ +sudo chmod -R u+rwX tmp/ + +# Create directory for satellites +sudo -u git -H mkdir /home/git/gitlab-satellites + +# Create directories for sockets/pids and make sure GitLab can write to them +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/ + +# Create public/uploads directory otherwise backup will fail +sudo -u git -H mkdir public/uploads +sudo chmod -R u+rwX public/uploads + +# Copy the example Unicorn config (Version < 5.1 use Unicorn, versions > 5.1 use Puma) +# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb + +# Copy the example of Puma config + +if [ "$useunicorn" -eq 1 ]; then + sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb + pumaorunicorn="puma" +else + sudo -u git -H cp config/puma.rb.example config/puma.rb + pumaorunicorn="unicorn" +fi + +# Configure Git global settings for git user +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 + +# ================================= +# = GitLab Database Configuration = +# ================================= + +# Mysql +sudo -u git cp config/database.yml.mysql config/database.yml + +# Insert database password into config +passwdph="secure password" +sed -i "s/${passwdph}/${gitlabpass}/g" config/database.yml + +# Replace MySQL user root with gitlab +sed -i 's/root/gitlab/g' config/database.yml + +# Make config/database.yml readable to git only +sudo -u git -H chmod o-rwx config/database.yml + +# ======================= +# = GitLab Gems Install = +# ======================= +# +cd /home/git/gitlab + +sudo gem install charlock_holmes --version '0.6.9.4' + +# For MySQL (note, the option says "without ... postgres") +sudo -u git -H bundle install --deployment --without development test postgres aws + + +# ================================================ +# = Initialize DB and Activate Advanced Features = +# ================================================ +sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production + +# ====================== +# = GitLab Init Script = +# ====================== +# +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab + +# Set GitLab to start on boot +sudo update-rc.d gitlab defaults 21 + +# =================== +# = Apache Handling = +# =================== +# +if [ -f /etc/init.d/apache2 ]; then + echo -e "\n[iGitLab] Apache init found, attempting to stop" + sudo /etc/init.d/apache2 stop + echo -e "\n[iGitLab] Disabling apache from starting at boot" + sudo update-rc.d apache2 remove +fi + +# ================= +# = Install Nginx = +# ================= +echo -e "\n[iGitLab] Attempting to install Nginx ..." +sudo apt-get install $aptget_arguments nginx +sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab +sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab + +# 5-3-stable and prior has YOUR_SERVER_IP in nginx conf, post 5-3-stable does not +sudo sed -i 's/YOUR_SERVER_IP:80/*:80/g' /etc/nginx/sites-available/gitlab + +# Replace YOUR_SERVER_FQDN with domain +sudo sed -i "s/YOUR_SERVER_FQDN/${domain_var}/g" /etc/nginx/sites-available/gitlab + +# =========================== +# = Where the magic happens = +# =========================== +sudo service gitlab start +sudo service nginx start + +echo "Install Complete." +echo -e "\n------------------------------------------------------------" +echo -e "\n[iGitLab] You can login at $domain_var" +echo -e "\n[iGitLab] Username: admin@local.host" +echo -e "\n[iGitLab] Password: 5iveL!fe" +echo -e "\n------------------------------------------------------------" diff --git a/install/ubuntu/ubuntu_server_1204.sh b/install/ubuntu/ubuntu_server_1204.sh deleted file mode 100644 index 901e92b..0000000 --- a/install/ubuntu/ubuntu_server_1204.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/sh - -# GITLAB -# Maintainer: @randx -# App Version: 4.0 - -# ABOUT -# This script performs a complete installation of Gitlab for ubuntu server 12.04.1 x64: -# * packages update -# * redis, git, postfix etc -# * ruby setup -# * git, gitlab users -# * gitolite fork -# Is should be run as root or sudo user w/o password. -# -# 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 -# - - -#== -#== 0. FQDN -#== - -if [ $domain_var ] ; then - 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 - -echo "Host $domain_var - 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. - - -#== -#== 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 -./configure -make -sudo make install -sudo gem install bundler - -#== -#== 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 - -#== -#== 4. Gitolite -#== - -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 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 - - -#== -#== 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 -# 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 -sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev - -#== -#== 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 - -# 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 - -# Copy the example Unicorn config -sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb - -cd /home/gitlab/gitlab - -sudo gem install charlock_holmes --version '0.6.9' -sudo -u gitlab -H bundle install --deployment --without development postgres test - -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/ -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 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 -