From 301c4068e13c838368fa2f5d9e2e9af2b2124c23 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Sat, 5 Apr 2014 20:31:07 +0100 Subject: [PATCH 1/4] Add rake task to install or upgrade gitlab-shell installation. --- lib/tasks/gitlab/shell.rake | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 08de0f2dd5..2fcc889d88 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -1,5 +1,63 @@ namespace :gitlab do namespace :shell do + desc "GITLAB | Install or upgrade gitlab-shell" + task :install, [:tag, :repo] => :environment do |t, args| + warn_user_is_not_gitlab + + args.with_defaults(tag: "v1.9.1", repo: "https://gitlab.com/gitlab-org/gitlab-shell.git") + + user = Settings.gitlab.user + home_dir = Settings.gitlab.user_home + gitlab_url = Settings.gitlab.url + # gitlab-shell requires a / at the end of the url + gitlab_url += "/" unless gitlab_url.match(/\/$/) + target_dir = File.join(home_dir, "gitlab-shell") + + # Clone if needed + unless File.directory?(target_dir) + sh "git clone '#{args.repo}' '#{target_dir}'" + end + + # Make sure we're on the right tag + Dir.chdir(target_dir) do + sh "git fetch origin && git reset --hard $(git describe #{args.tag} || git describe origin/#{args.tag})" + + redis_url = URI.parse(ENV['REDIS_URL'] || "redis://localhost:6379") + + config = { + user: user, + gitlab_url: gitlab_url, + http_settings: {self_signed_cert: false}, + repos_path: File.join(home_dir, "repositories"), + auth_file: File.join(home_dir, ".ssh", "authorized_keys"), + redis: { + bin: %x{which redis-cli}.chomp, + host: redis_url.host, + port: redis_url.port, + namespace: "resque:gitlab" + }, + log_level: "INFO", + audit_usernames: false + } + + # Generate config.yml based on existing gitlab settings + File.open("config.yml", "w+") {|f| f.puts config.to_yaml} + + # Launch installation process + sh "bin/install" + end + + # Required for debian packaging with PKGR: Setup .ssh/environment with + # the current PATH, so that the correct ruby version gets loaded + # Requires to set "PermitUserEnvironment yes" in sshd config (should not + # be an issue since it is more than likely that there are no "normal" + # user accounts on a gitlab server). The alternative is for the admin to + # install a ruby (1.9.3+) in the global path. + File.open(File.join(home_dir, ".ssh", "environment"), "w+") do |f| + f.puts "PATH=#{ENV['PATH']}" + end + end + desc "GITLAB | Setup gitlab-shell" task setup: :environment do setup From 8af8bee4538baa703085ccc2f44df2c967618ca4 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 8 Apr 2014 15:43:21 +0100 Subject: [PATCH 2/4] Add documentation for new rake task to install gitlab-shell. --- doc/install/installation.md | 41 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index e1fa822f7d..54527a8950 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -119,30 +119,7 @@ Create a `git` user for Gitlab: sudo adduser --disabled-login --gecos 'GitLab' git - -# 4. GitLab shell - -GitLab Shell is an ssh access and repository management software developed specially for GitLab. - - # Go to home directory - cd /home/git - - # Clone gitlab shell - sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.1 - - cd gitlab-shell - - sudo -u git -H cp config.yml.example config.yml - - # Edit config and replace gitlab_url - # with something like 'http://domain.com/' - sudo -u git -H editor config.yml - - # Do setup - sudo -u git -H ./bin/install - - -# 5. Database +# 4. Database We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md). @@ -165,7 +142,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da sudo -u git -H psql -d gitlabhq_production -# 6. GitLab +# 5. GitLab # We'll install GitLab into home directory of the user "git" cd /home/git @@ -275,6 +252,18 @@ that were [fixed](https://github.com/bundler/bundler/pull/2817) in 1.5.2. # When done you see 'Administrator account created:' +## Install GitLab shell + +GitLab Shell is an ssh access and repository management software developed specially for GitLab. + + # Go to the Gitlab installation folder: + cd /home/git/gitlab + + # Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): + sudo -u git -H bundle exec rake gitlab:shell:setup[v1.9.1] REDIS_URL=redis://localhost:6379 + + # By default, the gitlab-shell config is generated from your main gitlab config. You can review (and modify) it as follows: + sudo -u git -H editor /home/git/gitlab-shell/config.yml ## Install Init Script @@ -314,7 +303,7 @@ Check if GitLab and its environment are configured correctly: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production -# 7. Nginx +# 6. Nginx **Note:** 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 From c883660a3e754b5a3b14ef4a1be69503d345e3b5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 2 May 2014 13:46:15 +0300 Subject: [PATCH 3/4] Fix install docs for gitlab-shell setup rake task Signed-off-by: Dmitriy Zaporozhets --- doc/install/installation.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 821ea067e2..90d6f0e17e 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -27,10 +27,9 @@ The GitLab installation consists of setting up the following components: 1. Packages / Dependencies 2. Ruby 3. System Users -4. GitLab shell -5. Database -6. GitLab -7. Nginx +4. Database +5. GitLab +6. Nginx # 1. Packages / Dependencies @@ -261,7 +260,7 @@ GitLab Shell is an ssh access and repository management software developed speci cd /home/git/gitlab # Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): - sudo -u git -H bundle exec rake gitlab:shell:setup[v1.9.3] REDIS_URL=redis://localhost:6379 + sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.3] REDIS_URL=redis://localhost:6379 # By default, the gitlab-shell config is generated from your main gitlab config. You can review (and modify) it as follows: sudo -u git -H editor /home/git/gitlab-shell/config.yml From dd47f9532ff8015e3d981ba4fd7341b7514ae109 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 2 May 2014 13:46:32 +0300 Subject: [PATCH 4/4] Fix gitlab-shell setup rake task Signed-off-by: Dmitriy Zaporozhets --- lib/tasks/gitlab/shell.rake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 2fcc889d88..00901a89fb 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -11,7 +11,8 @@ namespace :gitlab do gitlab_url = Settings.gitlab.url # gitlab-shell requires a / at the end of the url gitlab_url += "/" unless gitlab_url.match(/\/$/) - target_dir = File.join(home_dir, "gitlab-shell") + repos_path = Gitlab.config.gitlab_shell.repos_path + target_dir = Gitlab.config.gitlab_shell.path # Clone if needed unless File.directory?(target_dir) @@ -28,7 +29,7 @@ namespace :gitlab do user: user, gitlab_url: gitlab_url, http_settings: {self_signed_cert: false}, - repos_path: File.join(home_dir, "repositories"), + repos_path: repos_path, auth_file: File.join(home_dir, ".ssh", "authorized_keys"), redis: { bin: %x{which redis-cli}.chomp, @@ -38,7 +39,7 @@ namespace :gitlab do }, log_level: "INFO", audit_usernames: false - } + }.stringify_keys # Generate config.yml based on existing gitlab settings File.open("config.yml", "w+") {|f| f.puts config.to_yaml}