Commit d74b8b450a8278e5f070eae6ebde69d97f6c69fc
Exists in
spb-stable
and in
2 other branches
Merge branch 'pkgr-improve-gitlab-shell-installation'
Showing
2 changed files
with
83 additions
and
30 deletions
Show diff stats
doc/install/installation.md
@@ -27,10 +27,9 @@ The GitLab installation consists of setting up the following components: | @@ -27,10 +27,9 @@ The GitLab installation consists of setting up the following components: | ||
27 | 1. Packages / Dependencies | 27 | 1. Packages / Dependencies |
28 | 2. Ruby | 28 | 2. Ruby |
29 | 3. System Users | 29 | 3. System Users |
30 | -4. GitLab shell | ||
31 | -5. Database | ||
32 | -6. GitLab | ||
33 | -7. Nginx | 30 | +4. Database |
31 | +5. GitLab | ||
32 | +6. Nginx | ||
34 | 33 | ||
35 | 34 | ||
36 | # 1. Packages / Dependencies | 35 | # 1. Packages / Dependencies |
@@ -119,30 +118,7 @@ Create a `git` user for Gitlab: | @@ -119,30 +118,7 @@ Create a `git` user for Gitlab: | ||
119 | 118 | ||
120 | sudo adduser --disabled-login --gecos 'GitLab' git | 119 | sudo adduser --disabled-login --gecos 'GitLab' git |
121 | 120 | ||
122 | - | ||
123 | -# 4. GitLab shell | ||
124 | - | ||
125 | -GitLab Shell is an ssh access and repository management software developed specially for GitLab. | ||
126 | - | ||
127 | - # Go to home directory | ||
128 | - cd /home/git | ||
129 | - | ||
130 | - # Clone gitlab shell | ||
131 | - sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.3 | ||
132 | - | ||
133 | - cd gitlab-shell | ||
134 | - | ||
135 | - sudo -u git -H cp config.yml.example config.yml | ||
136 | - | ||
137 | - # Edit config and replace gitlab_url | ||
138 | - # with something like 'http://domain.com/' | ||
139 | - sudo -u git -H editor config.yml | ||
140 | - | ||
141 | - # Do setup | ||
142 | - sudo -u git -H ./bin/install | ||
143 | - | ||
144 | - | ||
145 | -# 5. Database | 121 | +# 4. Database |
146 | 122 | ||
147 | We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md). | 123 | We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md). |
148 | 124 | ||
@@ -165,7 +141,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da | @@ -165,7 +141,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da | ||
165 | sudo -u git -H psql -d gitlabhq_production | 141 | sudo -u git -H psql -d gitlabhq_production |
166 | 142 | ||
167 | 143 | ||
168 | -# 6. GitLab | 144 | +# 5. GitLab |
169 | 145 | ||
170 | # We'll install GitLab into home directory of the user "git" | 146 | # We'll install GitLab into home directory of the user "git" |
171 | cd /home/git | 147 | cd /home/git |
@@ -276,6 +252,18 @@ that were [fixed](https://github.com/bundler/bundler/pull/2817) in 1.5.2. | @@ -276,6 +252,18 @@ that were [fixed](https://github.com/bundler/bundler/pull/2817) in 1.5.2. | ||
276 | 252 | ||
277 | # When done you see 'Administrator account created:' | 253 | # When done you see 'Administrator account created:' |
278 | 254 | ||
255 | +## Install GitLab shell | ||
256 | + | ||
257 | +GitLab Shell is an ssh access and repository management software developed specially for GitLab. | ||
258 | + | ||
259 | + # Go to the Gitlab installation folder: | ||
260 | + cd /home/git/gitlab | ||
261 | + | ||
262 | + # Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): | ||
263 | + sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.3] REDIS_URL=redis://localhost:6379 | ||
264 | + | ||
265 | + # By default, the gitlab-shell config is generated from your main gitlab config. You can review (and modify) it as follows: | ||
266 | + sudo -u git -H editor /home/git/gitlab-shell/config.yml | ||
279 | 267 | ||
280 | ## Install Init Script | 268 | ## Install Init Script |
281 | 269 | ||
@@ -313,7 +301,13 @@ Check if GitLab and its environment are configured correctly: | @@ -313,7 +301,13 @@ Check if GitLab and its environment are configured correctly: | ||
313 | # or | 301 | # or |
314 | sudo /etc/init.d/gitlab restart | 302 | sudo /etc/init.d/gitlab restart |
315 | 303 | ||
316 | -# 7. Nginx | 304 | + |
305 | +## Compile assets | ||
306 | + | ||
307 | + sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production | ||
308 | + | ||
309 | + | ||
310 | +# 6. Nginx | ||
317 | 311 | ||
318 | **Note:** | 312 | **Note:** |
319 | Nginx is the officially supported web server for GitLab. If you cannot or do not want to use Nginx as your web server, have a look at the | 313 | Nginx is the officially supported web server for GitLab. If you cannot or do not want to use Nginx as your web server, have a look at the |
lib/tasks/gitlab/shell.rake
1 | namespace :gitlab do | 1 | namespace :gitlab do |
2 | namespace :shell do | 2 | namespace :shell do |
3 | + desc "GITLAB | Install or upgrade gitlab-shell" | ||
4 | + task :install, [:tag, :repo] => :environment do |t, args| | ||
5 | + warn_user_is_not_gitlab | ||
6 | + | ||
7 | + args.with_defaults(tag: "v1.9.1", repo: "https://gitlab.com/gitlab-org/gitlab-shell.git") | ||
8 | + | ||
9 | + user = Settings.gitlab.user | ||
10 | + home_dir = Settings.gitlab.user_home | ||
11 | + gitlab_url = Settings.gitlab.url | ||
12 | + # gitlab-shell requires a / at the end of the url | ||
13 | + gitlab_url += "/" unless gitlab_url.match(/\/$/) | ||
14 | + repos_path = Gitlab.config.gitlab_shell.repos_path | ||
15 | + target_dir = Gitlab.config.gitlab_shell.path | ||
16 | + | ||
17 | + # Clone if needed | ||
18 | + unless File.directory?(target_dir) | ||
19 | + sh "git clone '#{args.repo}' '#{target_dir}'" | ||
20 | + end | ||
21 | + | ||
22 | + # Make sure we're on the right tag | ||
23 | + Dir.chdir(target_dir) do | ||
24 | + sh "git fetch origin && git reset --hard $(git describe #{args.tag} || git describe origin/#{args.tag})" | ||
25 | + | ||
26 | + redis_url = URI.parse(ENV['REDIS_URL'] || "redis://localhost:6379") | ||
27 | + | ||
28 | + config = { | ||
29 | + user: user, | ||
30 | + gitlab_url: gitlab_url, | ||
31 | + http_settings: {self_signed_cert: false}, | ||
32 | + repos_path: repos_path, | ||
33 | + auth_file: File.join(home_dir, ".ssh", "authorized_keys"), | ||
34 | + redis: { | ||
35 | + bin: %x{which redis-cli}.chomp, | ||
36 | + host: redis_url.host, | ||
37 | + port: redis_url.port, | ||
38 | + namespace: "resque:gitlab" | ||
39 | + }, | ||
40 | + log_level: "INFO", | ||
41 | + audit_usernames: false | ||
42 | + }.stringify_keys | ||
43 | + | ||
44 | + # Generate config.yml based on existing gitlab settings | ||
45 | + File.open("config.yml", "w+") {|f| f.puts config.to_yaml} | ||
46 | + | ||
47 | + # Launch installation process | ||
48 | + sh "bin/install" | ||
49 | + end | ||
50 | + | ||
51 | + # Required for debian packaging with PKGR: Setup .ssh/environment with | ||
52 | + # the current PATH, so that the correct ruby version gets loaded | ||
53 | + # Requires to set "PermitUserEnvironment yes" in sshd config (should not | ||
54 | + # be an issue since it is more than likely that there are no "normal" | ||
55 | + # user accounts on a gitlab server). The alternative is for the admin to | ||
56 | + # install a ruby (1.9.3+) in the global path. | ||
57 | + File.open(File.join(home_dir, ".ssh", "environment"), "w+") do |f| | ||
58 | + f.puts "PATH=#{ENV['PATH']}" | ||
59 | + end | ||
60 | + end | ||
61 | + | ||
3 | desc "GITLAB | Setup gitlab-shell" | 62 | desc "GITLAB | Setup gitlab-shell" |
4 | task setup: :environment do | 63 | task setup: :environment do |
5 | setup | 64 | setup |