Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorCyril Rohr <cyril.rohr@gmail.com>2014-04-05 23:31:07 +0400
committerCyril Rohr <cyril.rohr@gmail.com>2014-04-08 18:12:18 +0400
commit301c4068e13c838368fa2f5d9e2e9af2b2124c23 (patch)
tree64b0fb0ede5e9bb50bac64c8449e603d2fdcd71c /lib/tasks
parentfead96788c30c13b5adc25132cd003638a6d4f51 (diff)
Add rake task to install or upgrade gitlab-shell installation.
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/shell.rake58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index 08de0f2dd5d..2fcc889d883 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