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