Commit 301c4068 authored by Cyril Rohr's avatar Cyril Rohr

Add rake task to install or upgrade gitlab-shell installation.

parent fead9678
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
......
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