Commit 4bc7d98d65a84d037d6d8ddc807cdf0ceeb5a456
1 parent
08dfbc96
Exists in
master
and in
4 other branches
Remove hardcoded refernce to gitlab-shell home. so that gitlab can be installed …
…on any unix account other than git
Showing
2 changed files
with
13 additions
and
7 deletions
Show diff stats
lib/gitlab/backend/shell.rb
... | ... | @@ -10,7 +10,7 @@ module Gitlab |
10 | 10 | # add_repository("gitlab/gitlab-ci") |
11 | 11 | # |
12 | 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 | 14 | end |
15 | 15 | |
16 | 16 | # Import repository |
... | ... | @@ -21,7 +21,7 @@ module Gitlab |
21 | 21 | # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") |
22 | 22 | # |
23 | 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 | 25 | end |
26 | 26 | |
27 | 27 | # Remove repository from file system |
... | ... | @@ -32,7 +32,7 @@ module Gitlab |
32 | 32 | # remove_repository("gitlab/gitlab-ci") |
33 | 33 | # |
34 | 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 | 36 | end |
37 | 37 | |
38 | 38 | # Add new key to gitlab-shell |
... | ... | @@ -41,7 +41,7 @@ module Gitlab |
41 | 41 | # add_key("key-42", "sha-rsa ...") |
42 | 42 | # |
43 | 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 | 45 | end |
46 | 46 | |
47 | 47 | # Remove ssh key from gitlab shell |
... | ... | @@ -50,11 +50,16 @@ module Gitlab |
50 | 50 | # remove_key("key-342", "sha-rsa ...") |
51 | 51 | # |
52 | 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 | 54 | end |
55 | 55 | |
56 | 56 | def url_to_repo path |
57 | 57 | Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" |
58 | 58 | end |
59 | + | |
60 | + def gitlab_shell_user_home | |
61 | + File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") | |
62 | + end | |
63 | + | |
59 | 64 | end |
60 | 65 | end | ... | ... |
lib/tasks/gitlab/shell.rake
... | ... | @@ -25,12 +25,13 @@ namespace :gitlab do |
25 | 25 | def setup |
26 | 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 | 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 | 31 | ask_to_continue |
31 | 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 | 36 | Key.find_each(batch_size: 1000) do |key| |
36 | 37 | if Gitlab::Shell.new.add_key(key.shell_id, key.key) | ... | ... |