public
Last active

Install GitLab 5.0 on Archlinux

  • Download Gist
archgitlab.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
#!/bin/bash
 
##########################
## Check if run as root ##
##########################
 
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
 
######################################################################
## Before running this script, make sure to fill in these variables ##
######################################################################
 
# Enable or disable ruby docs installation
RUBY_DOCS_ENABLED=False
 
# mysql or postgresql
DB=mysql
 
# database name
DB_NAME=gitlabhq_production
 
DB_ROOT_PASSWD=
DB_GITLAB_PASSWD=
DB_GITLAB_USERNAME=
 
# Set branch to pull from
BRANCH=master
 
# Fully-qualified domain name
FQDN=
 
 
##############################
## 1. Install prerequisites ##
##############################
 
pacman -Syu --noconfirm --needed sudo base-devel zlib libyaml openssl gdbm readline ncurses libffi curl git openssh redis postfix libxml2 libxslt icu python2 ruby
 
## Add ruby exec to PATH
 
echo "export PATH=/root/.gem/ruby/1.9.1/bin:$PATH" >> /root/.bash_profile
source /root/.bashrc
 
 
#####################################
## 3. Create a git user for Gitlab ##
#####################################
 
useradd --create-home --comment 'GitLab' git
 
#####################
## 3. GitLab shell ##
#####################
 
# Login as git
su - git
 
# Clone gitlab shell
git clone https://github.com/gitlabhq/gitlab-shell.git
 
# Setup
cd gitlab-shell
cp config.yml.example config.yml
 
# Change "localhost" to the fully-qualified domain name
sed -i "s/localhost/$FQDN/g" config.yml
 
./bin/install
 
exit
 
#################################################################
## 3 Install and configure GitLab. Check status configuration. ##
#################################################################
 
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab/
# Checkout to stable release
sudo -u git -H git checkout $BRANCH
 
# Copy the example GitLab config
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
 
# Change "localhost" to the fully-qualified domain name
sed -i "s/localhost/$FQDN/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/puma.rb.example config/puma.rb
 
# Configure Git global settings for git user, useful when editing via web
# Edit user.email according to what is set in gitlab.yml
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@localhost"
 
# Start redis server
systemctl enable redis
systemctl start redis
 
## Configure GitLab DB settings / Install Gems
 
if [ RUBY_DOCS_ENABLED -eq False ]; then
 
echo "gem: --no-rdoc --no-ri" >> /home/git/.gemrc
 
fi
 
gem install charlock_holmes --version '0.6.9.4'
 
if [[ $DB -eq 'mysql' ]]; then
 
pacman -S --needed --noconfirm mysql
sudo -u git cp config/database.yml.mysql config/database.yml
sed -i "s/gitlabhq_production/$DB_NAME/" config/database.yml
sed -i "s/root/$DB_GITLAB_USERNAME/" config/database.yml
sed -i "s/secure password/$DB_GITLAB_PASSWD/" config/database.yml
sudo -u git -H bundle install --deployment --without development test postgres
elif [[ $DB -eq 'postgresql' ]]; then
 
pacman -S --needed --noconfirm postgresql
sudo -u git cp config/database.yml.postgresql config/database.yml
sed -i "s/gitlabhq_production/$DB_NAME/" config/database.yml
sed -i "s/gitlab/$DB_GITLAB_USERNAME/" config/database.yml
sed -i 's/password:/password: $DB_GITLAB_PASSWD/' config/database.yml
sudo -u git -H bundle install --deployment --without development test mysql
fi
 
 
 
## Initialise Database and Activate Advanced Features
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
 
 
## Check Application Status
 
# Check if GitLab and its environment are configured correctly
 
# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
 
# To make sure you didn't miss anything run a more thorough check with
 
# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
 
 
# 7. Nginx
 
## Installation
pacman -S nginx
 
# Download an example site config
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
 
# Edit the config file to match your setup
sed -i "s/YOUR_SERVER_IP:80/80/" /etc/nginx/sites-available/gitlab
sed -i "s/YOUR_SERVER_FQDN/$FQDN/" /etc/nginx/sites-available/gitlab
 
# Restart and enable on boot
systemctl restart nginx
systemctl enable nginx
 
 
echo "Done!"
echo "Visit $FQDN for your first GitLab login."
echo "The setup has created an admin account for you."
echo "Please go over to your profile page and immediately change the password."
echo "##################################"
echo "## Email.....: admin@local.host ##"
echo "## Password..: 5iveL!fe ##"
ehco "##################################"
dependencies
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Debian Archlinux Repository
--------------------------------------------------
sudo sudo core
build-essential base-devel core
zlib1g-dev zlib core
libyaml-dev libyaml community
libssl-dev openssl core
libgdbm-dev gdbm core
libreadline-dev readline core
libncurses5-dev ncurses core
libffi-dev libffi core
curl curl core
git-core git extra
openssh-server openssh core
redis-server redis community
postfix postfix extra
checkinstall checkinstall community
libxml2-dev libxml2 extra
libxslt-dev libxslt extra
libcurl4-openssl-dev curl core
libicu-dev icu extra
python python2 extra
gitlab.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# https://github.com/gitlabhq/gitlab-recipes/issues/14#issuecomment-9997442
#
# GITLAB
# Maintainer: @axilleas
# App Version: 5.0
#
 
[Unit]
Description=Self Hosted Git Management
Requires=mysql.service redis.service
After=mysql.service redis.service
Wants=postfix.service sidekiq.service
 
[Service]
Type=forking
User=git
WorkingDirectory=/home/git/gitlab
ExecStart=/home/git/gitlab/script/rails server -d -e production
PIDFile=/home/git/gitlab/tmp/pids/server.pid
 
[Install]
WantedBy=multi-user.target
sidekiq.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# https://github.com/davispuh/gitlab-recipes/blob/0704f62d31573d9d3b4d2e1417e464e29d8c0d1b/systemd/sidekiq.service
#
# GITLAB
# Maintainer: @davispuh
# App Version: 5.0
#
 
[Unit]
Description=GitLab Sidekiq Service
After=syslog.target network.target remote-fs.target nss-lookup.target redis.service
Wants=redis.service
 
[Service]
Type=simple
PIDFile=/home/git/gitlab/tmp/pids/sidekiq.pid
User=git
WorkingDirectory=/home/git/gitlab/
ExecStart=/bin/su - git -c "bundle exec rake sidekiq:start RAILS_ENV=production"
ExecStop=/bin/su - git -c "bundle exec rake sidekiq:stop RAILS_ENV=production"
 
[Install]
WantedBy=multi-user.target

Hi, could you make a pull request with this to https://github.com/gitlabhq/gitlab-recipes? I think it would be useful for people and you can get credit for helping out. Thanks!

I just saw your comment... There are a couple of things changed since the last time I wrote this, so it must be rewritten at some points. I'll look into it during this week, thanks!

what's the current state? I've checked https://github.com/gitlabhq/gitlab-recipes, it looks like have not been merged.

I haven't sent a pull request yet as this is quite outdated. I will edit it to match the master branch (the upcoming 5.0 release which is scheduled on March 22nd).

why ruby things is installed in root directory? maybe we can install them into /home/git.

the nginx script link become invalid, and can you add some info for apache

Updated. Although I don't know if anyone is using it. It needs testing and I don't have time right now...

line 194 typo in "echo"
also in line 59, this just leaves the terminal open as the git user and doesn't really issue any commands

still testing ;-)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.