From f239f08ec3011237fd76563c9e8f751523496f14 Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Wed, 17 Jul 2013 22:12:34 -0400 Subject: [PATCH 1/6] add v5 installer --- install/v5/ubuntu_server_1204.sh | 263 +++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 install/v5/ubuntu_server_1204.sh diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh new file mode 100644 index 0000000..b67e08f --- /dev/null +++ b/install/v5/ubuntu_server_1204.sh @@ -0,0 +1,263 @@ +# @title GitLab v5 Ubuntu/Debian Installer +# ------------------------------------------------------------------------------------------ +# @author Myles McNamara +# @date 7.17.2013 +# @version 1.0 +# @source https://github.com/tripflex/gitlab-recipes/ +# ------------------------------------------------------------------------------------------ +# @usage ./ubuntu_server_1204.sh 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 = +# ======================================== +gitlab_release=5-3-stable + +if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then + echo "Usage: $0 domain.com" >&2 + exit +fi + +clear +echo "### Feeding the rabbit, here we go..." +if [ "$#" -lt 1 ]; then + echo "=== Domain was not specified, using localhost as default" + domain_var=localhost +fi + +echo "=== Installing GitLab v5 (Release: $gitlab_release) for $domain_var" + +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 + + +# ==================== +# = Install Packages = +# ==================== +# +sudo apt-get update +sudo apt-get install -y 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 + +# ======================= +# = Python Installation = +# ======================= +# +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 Install = +# =================== +# +sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python postfix # Install postfix without prompting. + + +# ===================== +# = Ruby Installation = +# ===================== +# +curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz +cd ruby-2.0.0-p247 +./configure +make +sudo make install + +# Bundler Gem +sudo gem install bundler --no-ri --no-rdoc + +# ================ +# = System Users = +# ================ +# +# Create 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 v1.4.0 +# 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 + +# ====================== +# = MySQL Installation = +# ====================== +# +sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively. +mysqlPassword=$(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 $mysqlPassword | sudo debconf-set-selections +echo mysql-server mysql-server/root_password_again password $mysqlPassword | sudo debconf-set-selections +sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + +# ======================= +# = 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 Puma config +sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb + +# 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" + +# ================================= +# = GitLab Database Configuration = +# ================================= + +# Mysql +sudo -u git cp config/database.yml.mysql config/database.yml + +# Insert database password into config +sed -i 's/"secure password"/$mysqlPassword/g' config/database.yml + +# Replace MySQL user root with gitlab +# /** + +# TODO: +# - Setup MySQL DB with gitlab user instead of root + +# **/ +#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 unicorn 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 "=== Apache init found, attempting to stop" + sudo /etc/init.d/apache2 stop + echo "=== Disabling apache from starting at boot" + sudo update-rc.d apache2 remove +fi + +# ================= +# = Install Nginx = +# ================= +echo "=== Attempting to install Nginx ..." +sudo apt-get install -y 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 +# 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 + From 6d58157e83092461753643e6c857e0c2c528448c Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Wed, 17 Jul 2013 23:10:44 -0400 Subject: [PATCH 2/6] remove lt check, add apt-get arguments --- install/v5/ubuntu_server_1204.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh index b67e08f..16355f3 100644 --- a/install/v5/ubuntu_server_1204.sh +++ b/install/v5/ubuntu_server_1204.sh @@ -24,8 +24,9 @@ # = Required Script Configuration Values = # ======================================== gitlab_release=5-3-stable +aptget_arguments="-y -q" -if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then echo "Usage: $0 domain.com" >&2 exit fi @@ -53,19 +54,19 @@ echo "Host $domain_var # ==================== # sudo apt-get update -sudo apt-get install -y 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 +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 # ======================= # = Python Installation = # ======================= # -sudo apt-get install -y 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 python2.7 +sudo apt-get install $aptget_arguments python2.7 # Make sure you can access Python via python2 python2 --version @@ -77,7 +78,7 @@ sudo ln -s /usr/bin/python /usr/bin/python2 # = Postfix Install = # =================== # -sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python postfix # Install postfix without prompting. +sudo DEBIAN_FRONTEND='noninteractive' apt-get install $aptget_arguments postfix-policyd-spf-python postfix # Install postfix without prompting. # ===================== @@ -125,13 +126,13 @@ sudo -u git -H ./bin/install # = MySQL Installation = # ====================== # -sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively. +sudo apt-get install $aptget_arguments makepasswd # Needed to create a unique password non-interactively. mysqlPassword=$(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 $mysqlPassword | sudo debconf-set-selections echo mysql-server mysql-server/root_password_again password $mysqlPassword | sudo debconf-set-selections -sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev +sudo apt-get install $aptget_arguments mysql-server mysql-client libmysqlclient-dev # ======================= # = GitLab Installation = @@ -249,9 +250,13 @@ fi # = Install Nginx = # ================= echo "=== Attempting to install Nginx ..." -sudo apt-get install -y 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 From 2e9424ebe52fde88f2548d0595f58b64d34dbb55 Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Thu, 18 Jul 2013 00:11:41 -0400 Subject: [PATCH 3/6] apt quiet, other enhancements --- install/v5/ubuntu_server_1204.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh index 16355f3..88fdb7d 100644 --- a/install/v5/ubuntu_server_1204.sh +++ b/install/v5/ubuntu_server_1204.sh @@ -24,7 +24,15 @@ # = Required Script Configuration Values = # ======================================== gitlab_release=5-3-stable -aptget_arguments="-y -q" + +# ============================== +# = 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" if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then echo "Usage: $0 domain.com" >&2 From 00f6b1a1273e9a3d89cd323a0b0411ad41656e2a Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Thu, 18 Jul 2013 00:15:36 -0400 Subject: [PATCH 4/6] should prob click save in sublime --- install/v5/ubuntu_server_1204.sh | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh index 88fdb7d..402a8ad 100644 --- a/install/v5/ubuntu_server_1204.sh +++ b/install/v5/ubuntu_server_1204.sh @@ -40,34 +40,28 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then fi clear -echo "### Feeding the rabbit, here we go..." +echo -e "\nFeeding the rabbit, here we go..." if [ "$#" -lt 1 ]; then - echo "=== Domain was not specified, using localhost as default" + echo -e "\n !! Domain was not specified, using localhost as default !!" domain_var=localhost fi -echo "=== Installing GitLab v5 (Release: $gitlab_release) for $domain_var" - -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 - +echo -e "\nInstalling GitLab v5 (Release: $gitlab_release) for $domain_var" # ==================== # = Install Packages = # ==================== # +echo -e "\nUpdating package information..." sudo apt-get update +echo -e "\nInstalling required packages..." 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 # ======================= # = Python Installation = # ======================= -# +# +echo -e "\n" sudo apt-get install $aptget_arguments python # Make sure that Python is 2.x (3.x is not supported at the moment) @@ -248,16 +242,16 @@ sudo update-rc.d gitlab defaults 21 # =================== # if [ -f /etc/init.d/apache2 ]; then - echo "=== Apache init found, attempting to stop" + echo -e "\n=== Apache init found, attempting to stop" sudo /etc/init.d/apache2 stop - echo "=== Disabling apache from starting at boot" + echo -e "\n=== Disabling apache from starting at boot" sudo update-rc.d apache2 remove fi # ================= # = Install Nginx = # ================= -echo "=== Attempting to install Nginx ..." +echo -e "\n=== 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 From 3806e232923a359a5e84e46caa5d8d2ff84fdf58 Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Tue, 23 Jul 2013 11:16:32 -0400 Subject: [PATCH 5/6] import igitlab --- install/v5/ubuntu_server_1204.sh | 239 ++++++++++++++++++++++--------- 1 file changed, 174 insertions(+), 65 deletions(-) diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh index 402a8ad..c4b860d 100644 --- a/install/v5/ubuntu_server_1204.sh +++ b/install/v5/ubuntu_server_1204.sh @@ -1,12 +1,23 @@ -# @title GitLab v5 Ubuntu/Debian Installer -# ------------------------------------------------------------------------------------------ +#!/bin/bash +# +# 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"' +# +# Ubuntu/Debian Installer +# ------------------------------------------------------------------------------ # @author Myles McNamara # @date 7.17.2013 # @version 1.0 -# @source https://github.com/tripflex/gitlab-recipes/ -# ------------------------------------------------------------------------------------------ -# @usage ./ubuntu_server_1204.sh domain.com -# ------------------------------------------------------------------------------------------ +# @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 @@ -18,21 +29,61 @@ # 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 = -# ======================================== -gitlab_release=5-3-stable - -# ============================== -# = Optional apt-get arguments = -# ============================== +# ------------------------------------------------------------------------------ + +# ============================================================================= +# = 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=5-4-stable +# ------------------------------------------------------- +# - Unicorn or Puma, Puma default, set to 1 for Unicorn - +# ------------------------------------------------------- + useunicorn=0 +# ------------------------------------- +# - Download URL for Ruby tar.gz file - +# ------------------------------------- +# 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" +# ------------------------------ + 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 +} + +# ====================== +# = General Start Code = +# ====================== if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then echo "Usage: $0 domain.com" >&2 @@ -40,28 +91,79 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then fi clear -echo -e "\nFeeding the rabbit, here we go..." + +# Check for domain if [ "$#" -lt 1 ]; then - echo -e "\n !! Domain was not specified, using localhost as default !!" - domain_var=localhost + echo -e "\n[iGitLab] Domain was not specified, using localhost as default!" + domain_var=localhost +else + domain_var=$1 fi -echo -e "\nInstalling GitLab v5 (Release: $gitlab_release) for $domain_var" +# Check for MySQL root password +if [ -z "$mysqlpasswd" ]; then + echo -e "\n[iGitLab] MySQL root password not set in configuration, this will be required. If MySQL is not installed you will be prompted to set a password after this script installs MySQL. If MySQL is already installed you will need to set the root password and restart this script." +fi + +echo -e "\n[iGitLab] Installing GitLab v5 (Release: $gitlab_release) for $domain_var" + +givemeayes "Would you like to continue with the install? (y/n)" # ==================== # = Install Packages = # ==================== # -echo -e "\nUpdating package information..." -sudo apt-get update -echo -e "\nInstalling required packages..." -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 +echo -e "\n[iGitLab] Updating package information..." +sudo apt-get update $aptget_arguments +echo -e "\n[iGitLab] 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 makepasswd 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=$(makepasswd --char=14) + +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" +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) @@ -82,25 +184,33 @@ sudo ln -s /usr/bin/python /usr/bin/python2 # sudo DEBIAN_FRONTEND='noninteractive' apt-get install $aptget_arguments postfix-policyd-spf-python postfix # Install postfix without prompting. - # ===================== # = Ruby Installation = # ===================== -# -curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz -cd ruby-2.0.0-p247 -./configure -make -sudo make install - -# Bundler Gem -sudo gem install bundler --no-ri --no-rdoc +# +# 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 # ============================= @@ -119,23 +229,11 @@ sudo -u git -H git checkout v1.4.0 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 +sudo -u git -H sed -i "s/localhost/${domain_var}/g" config.yml # Do setup sudo -u git -H ./bin/install -# ====================== -# = MySQL Installation = -# ====================== -# -sudo apt-get install $aptget_arguments makepasswd # Needed to create a unique password non-interactively. -mysqlPassword=$(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 $mysqlPassword | sudo debconf-set-selections -echo mysql-server mysql-server/root_password_again password $mysqlPassword | sudo debconf-set-selections -sudo apt-get install $aptget_arguments mysql-server mysql-client libmysqlclient-dev - # ======================= # = GitLab Installation = # ======================= @@ -160,7 +258,7 @@ cd /home/git/gitlab 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 +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/ @@ -181,8 +279,18 @@ sudo chmod -R u+rwX tmp/sockets/ sudo -u git -H mkdir public/uploads sudo chmod -R u+rwX public/uploads -# Copy the example Puma config -sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb +# 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" @@ -196,16 +304,11 @@ sudo -u git -H git config --global user.email "gitlab@$domain_var" sudo -u git cp config/database.yml.mysql config/database.yml # Insert database password into config -sed -i 's/"secure password"/$mysqlPassword/g' config/database.yml +passwdph="secure password" +sed -i "s/${passwdph}/${gitlabpass}/g" config/database.yml # Replace MySQL user root with gitlab -# /** - -# TODO: -# - Setup MySQL DB with gitlab user instead of root - -# **/ -#sed -i 's/root/gitlab/g' config/database.yml +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 @@ -219,7 +322,7 @@ 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 unicorn aws +sudo -u git -H bundle install --deployment --without development test postgres aws $pumaorunicorn # ================================================ @@ -242,16 +345,16 @@ sudo update-rc.d gitlab defaults 21 # =================== # if [ -f /etc/init.d/apache2 ]; then - echo -e "\n=== Apache init found, attempting to stop" + echo -e "\n[iGitLab] Apache init found, attempting to stop" sudo /etc/init.d/apache2 stop - echo -e "\n=== Disabling apache from starting at boot" + echo -e "\n[iGitLab] Disabling apache from starting at boot" sudo update-rc.d apache2 remove fi # ================= # = Install Nginx = # ================= -echo -e "\n=== Attempting to 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 @@ -260,7 +363,7 @@ sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab 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 +sudo sed -i "s/YOUR_SERVER_FQDN/${domain_var}/g" /etc/nginx/sites-available/gitlab # =========================== # = Where the magic happens = @@ -268,3 +371,9 @@ sudo sed -i "s/YOUR_SERVER_FQDN/$domain_var/g" /etc/nginx/sites-available/gitlab 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------------------------------------------------------------" From c8e5aa98f47b74d0ff0ed98d3ed905799c697b24 Mon Sep 17 00:00:00 2001 From: Myles McNamara Date: Tue, 23 Jul 2013 11:18:22 -0400 Subject: [PATCH 6/6] update header --- install/v5/ubuntu_server_1204.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/v5/ubuntu_server_1204.sh b/install/v5/ubuntu_server_1204.sh index c4b860d..855071f 100644 --- a/install/v5/ubuntu_server_1204.sh +++ b/install/v5/ubuntu_server_1204.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# 88 ,ad8888ba, 88 88 88 +# 88 ,ad8888ba, 88 88 88 # "" d8"' `"8b "" ,d 88 88 # d8' 88 88 88 # 88 88 88 MM88MMM 88 ,adPPYYba, 88,dPPYba,