Skip to content

Commit a38d8cc

Browse files
committed
One script installer for ubuntu server 12.04
1 parent ee18f65 commit a38d8cc

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed

install/v4/ubuntu_server_1204.sh

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/bin/sh
2+
3+
# GITLAB
4+
# Maintainer: @randx
5+
# App Version: 4.0
6+
7+
# ABOUT
8+
# This script performs a complete installation of Gitlab for ubuntu server 12.04.1 x64:
9+
# * packages update
10+
# * redis, git, postfix etc
11+
# * ruby setup
12+
# * git, gitlab users
13+
# * gitolite fork
14+
# Is should be run as root or sudo user.
15+
#
16+
# USAGE
17+
# curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/v4/ubuntu_server_1204.sh | sudo domain_var=gitlab.example.com sh
18+
#
19+
20+
21+
#==
22+
#== 0. FQDN
23+
#==
24+
25+
if [ $domain_var ] ; then
26+
echo "Installing GitLab for domain: $domain_var"
27+
else
28+
echo "Please pass domain_var"
29+
exit
30+
fi
31+
32+
33+
#==
34+
#== 1. Packages
35+
#==
36+
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
37+
38+
39+
# Python
40+
41+
# Install Python
42+
sudo apt-get install python
43+
44+
# Make sure that Python is 2.x (3.x is not supported at the moment)
45+
python --version
46+
47+
# If it's Python 3 you might need to install Python 2 separately
48+
sudo apt-get install python2.7
49+
50+
# Make sure you can access Python via python2
51+
python2 --version
52+
53+
# If you get a "command not found" error create a link to the python binary
54+
sudo ln -s /usr/bin/python /usr/bin/python2
55+
56+
# POSTFIX
57+
sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python postfix # Install postfix without prompting.
58+
59+
60+
#==
61+
#== 2. RUBY
62+
#==
63+
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
64+
tar xfvz ruby-1.9.3-p327.tar.gz
65+
cd ruby-1.9.3-p327
66+
./configure
67+
make
68+
sudo make install
69+
sudo gem install bundler
70+
71+
#==
72+
#== 3. Users
73+
#==
74+
sudo adduser \
75+
--system \
76+
--shell /bin/sh \
77+
--gecos 'Git Version Control' \
78+
--group \
79+
--disabled-password \
80+
--home /home/git \
81+
git
82+
83+
84+
sudo adduser --disabled-login --gecos 'GitLab' gitlab
85+
86+
# Add it to the git group
87+
sudo usermod -a -G git gitlab
88+
89+
# Generate the SSH key
90+
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
91+
92+
#==
93+
#== 4. Gitolite
94+
#==
95+
96+
cd /home/git
97+
sudo -u git -H git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
98+
# Add Gitolite scripts to $PATH
99+
sudo -u git -H mkdir /home/git/bin
100+
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile'
101+
sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
102+
103+
# Copy the gitlab user's (public) SSH key ...
104+
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
105+
sudo chmod 0444 /home/git/gitlab.pub
106+
107+
# ... and use it as the admin key for the Gitolite setup
108+
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
109+
110+
sudo chmod -R ug+rwXs /home/git/repositories/
111+
sudo chown -R git:git /home/git/repositories/
112+
113+
echo "Host localhost
114+
StrictHostKeyChecking no
115+
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config
116+
117+
118+
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
119+
sudo rm -rf /tmp/gitolite-admin
120+
121+
122+
#==
123+
#== 5. MySQL
124+
#==
125+
sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively.
126+
userPassword=$(makepasswd --char=10) # Generate a random MySQL password
127+
# Note that the lines below creates a cleartext copy of the random password in /var/cache/debconf/passwords.dat
128+
# This file is normally only readable by root and the password will be deleted by the package management system after install.
129+
echo mysql-server mysql-server/root_password password $userPassword | sudo debconf-set-selections
130+
echo mysql-server mysql-server/root_password_again password $userPassword | sudo debconf-set-selections
131+
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
132+
133+
#==
134+
#== 6. GitLab
135+
#==
136+
cd /home/gitlab
137+
sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
138+
cd /home/gitlab/gitlab
139+
# Checkout v4
140+
sudo -u gitlab -H git checkout fa203e8b67b3e8fd25ab1edd0ccbedc6072563b2
141+
142+
# Copy the example GitLab config
143+
sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
144+
sudo -u gitlab -H cp config/database.yml.mysql config/database.yml
145+
sudo sed -i 's/"secure password"/"'$userPassword'"/' /home/gitlab/gitlab/config/database.yml # Insert the mysql root password.
146+
sudo sed -i "s/host: localhost/host: $domain_var/" /home/gitlab/gitlab/config/gitlab.yml
147+
sudo sed -i "s/notify@localhost/notify@$domain_var/" /home/gitlab/gitlab/config/gitlab.yml
148+
149+
# Copy the example Unicorn config
150+
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
151+
152+
cd /home/gitlab/gitlab
153+
154+
sudo gem install charlock_holmes --version '0.6.9'
155+
sudo -u gitlab -H bundle install --deployment --without development postgres test
156+
157+
sudo -u gitlab -H git config --global user.name "GitLab"
158+
sudo -u gitlab -H git config --global user.email "gitlab@localhost"
159+
160+
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
161+
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
162+
163+
sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production
164+
165+
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
166+
sudo chmod +x /etc/init.d/gitlab
167+
168+
sudo update-rc.d gitlab defaults 21
169+
170+
171+
#==
172+
#== 7. Nginx
173+
#==
174+
sudo apt-get install nginx
175+
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
176+
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
177+
178+
179+
sudo sed -i 's/YOUR_SERVER_IP:80/80/' /etc/nginx/sites-available/gitlab # Set Domain
180+
sudo sed -i "s/YOUR_SERVER_FQDN/$domain_var/" /etc/nginx/sites-available/gitlab
181+
182+
183+
# Start all
184+
185+
sudo service gitlab start
186+
sudo service nginx start
187+

0 commit comments

Comments
 (0)