Commit 4bc7d98d65a84d037d6d8ddc807cdf0ceeb5a456

Authored by Bhagavan Das
1 parent 08dfbc96

Remove hardcoded refernce to gitlab-shell home. so that gitlab can be installed …

…on any unix account other than git
lib/gitlab/backend/shell.rb
@@ -10,7 +10,7 @@ module Gitlab @@ -10,7 +10,7 @@ module Gitlab
10 # add_repository("gitlab/gitlab-ci") 10 # add_repository("gitlab/gitlab-ci")
11 # 11 #
12 def add_repository(name) 12 def add_repository(name)
13 - system("/home/git/gitlab-shell/bin/gitlab-projects add-project #{name}.git") 13 + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects add-project #{name}.git")
14 end 14 end
15 15
16 # Import repository 16 # Import repository
@@ -21,7 +21,7 @@ module Gitlab @@ -21,7 +21,7 @@ module Gitlab
21 # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") 21 # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
22 # 22 #
23 def import_repository(name, url) 23 def import_repository(name, url)
24 - system("/home/git/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}") 24 + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}")
25 end 25 end
26 26
27 # Remove repository from file system 27 # Remove repository from file system
@@ -32,7 +32,7 @@ module Gitlab @@ -32,7 +32,7 @@ module Gitlab
32 # remove_repository("gitlab/gitlab-ci") 32 # remove_repository("gitlab/gitlab-ci")
33 # 33 #
34 def remove_repository(name) 34 def remove_repository(name)
35 - system("/home/git/gitlab-shell/bin/gitlab-projects rm-project #{name}.git") 35 + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects rm-project #{name}.git")
36 end 36 end
37 37
38 # Add new key to gitlab-shell 38 # Add new key to gitlab-shell
@@ -41,7 +41,7 @@ module Gitlab @@ -41,7 +41,7 @@ module Gitlab
41 # add_key("key-42", "sha-rsa ...") 41 # add_key("key-42", "sha-rsa ...")
42 # 42 #
43 def add_key(key_id, key_content) 43 def add_key(key_id, key_content)
44 - system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"") 44 + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
45 end 45 end
46 46
47 # Remove ssh key from gitlab shell 47 # Remove ssh key from gitlab shell
@@ -50,11 +50,16 @@ module Gitlab @@ -50,11 +50,16 @@ module Gitlab
50 # remove_key("key-342", "sha-rsa ...") 50 # remove_key("key-342", "sha-rsa ...")
51 # 51 #
52 def remove_key(key_id, key_content) 52 def remove_key(key_id, key_content)
53 - system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") 53 + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
54 end 54 end
55 55
56 def url_to_repo path 56 def url_to_repo path
57 Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" 57 Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
58 end 58 end
  59 +
  60 + def gitlab_shell_user_home
  61 + File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
  62 + end
  63 +
59 end 64 end
60 end 65 end
lib/tasks/gitlab/shell.rake
@@ -25,12 +25,13 @@ namespace :gitlab do @@ -25,12 +25,13 @@ namespace :gitlab do
25 def setup 25 def setup
26 warn_user_is_not_gitlab 26 warn_user_is_not_gitlab
27 27
  28 + gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
28 puts "This will rebuild an authorized_keys file." 29 puts "This will rebuild an authorized_keys file."
29 - puts "You will lose any data stored in /home/git/.ssh/authorized_keys." 30 + puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
30 ask_to_continue 31 ask_to_continue
31 puts "" 32 puts ""
32 33
33 - system("echo '# Managed by gitlab-shell' > /home/git/.ssh/authorized_keys") 34 + system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
34 35
35 Key.find_each(batch_size: 1000) do |key| 36 Key.find_each(batch_size: 1000) do |key|
36 if Gitlab::Shell.new.add_key(key.shell_id, key.key) 37 if Gitlab::Shell.new.add_key(key.shell_id, key.key)