Commit d74b8b45 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'pkgr-improve-gitlab-shell-installation'

parents b2a25872 dd47f953
...@@ -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:
1. Packages / Dependencies 1. Packages / Dependencies
2. Ruby 2. Ruby
3. System Users 3. System Users
4. GitLab shell 4. Database
5. Database 5. GitLab
6. GitLab 6. Nginx
7. Nginx
# 1. Packages / Dependencies # 1. Packages / Dependencies
...@@ -119,30 +118,7 @@ Create a `git` user for Gitlab: ...@@ -119,30 +118,7 @@ Create a `git` user for Gitlab:
sudo adduser --disabled-login --gecos 'GitLab' git sudo adduser --disabled-login --gecos 'GitLab' git
# 4. Database
# 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.3
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
We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md). We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md).
...@@ -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
sudo -u git -H psql -d gitlabhq_production sudo -u git -H psql -d gitlabhq_production
# 6. GitLab # 5. GitLab
# We'll install GitLab into home directory of the user "git" # We'll install GitLab into home directory of the user "git"
cd /home/git 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.
# When done you see 'Administrator account created:' # 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: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
## Install Init Script ## Install Init Script
...@@ -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:
# or # or
sudo /etc/init.d/gitlab restart sudo /etc/init.d/gitlab restart
# 7. Nginx
## Compile assets
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
# 6. Nginx
**Note:** **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 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
......
namespace :gitlab do namespace :gitlab do
namespace :shell 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(/\/$/)
repos_path = Gitlab.config.gitlab_shell.repos_path
target_dir = Gitlab.config.gitlab_shell.path
# 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: repos_path,
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
}.stringify_keys
# 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" desc "GITLAB | Setup gitlab-shell"
task setup: :environment do task setup: :environment do
setup setup
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment