Skip to content
Snippets Groups Projects
Commit 4bc7d98d authored by Bhagavan Das's avatar Bhagavan Das
Browse files

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

Remove hardcoded refernce to gitlab-shell home. so that gitlab can be installed on any unix account other than git
parent 08dfbc96
No related branches found
No related tags found
No related merge requests found
Loading
@@ -10,7 +10,7 @@ module Gitlab
Loading
@@ -10,7 +10,7 @@ module Gitlab
# add_repository("gitlab/gitlab-ci") # add_repository("gitlab/gitlab-ci")
# #
def add_repository(name) def add_repository(name)
system("/home/git/gitlab-shell/bin/gitlab-projects add-project #{name}.git") system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects add-project #{name}.git")
end end
   
# Import repository # Import repository
Loading
@@ -21,7 +21,7 @@ module Gitlab
Loading
@@ -21,7 +21,7 @@ module Gitlab
# import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
# #
def import_repository(name, url) def import_repository(name, url)
system("/home/git/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}") system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}")
end end
   
# Remove repository from file system # Remove repository from file system
Loading
@@ -32,7 +32,7 @@ module Gitlab
Loading
@@ -32,7 +32,7 @@ module Gitlab
# remove_repository("gitlab/gitlab-ci") # remove_repository("gitlab/gitlab-ci")
# #
def remove_repository(name) def remove_repository(name)
system("/home/git/gitlab-shell/bin/gitlab-projects rm-project #{name}.git") system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects rm-project #{name}.git")
end end
   
# Add new key to gitlab-shell # Add new key to gitlab-shell
Loading
@@ -41,7 +41,7 @@ module Gitlab
Loading
@@ -41,7 +41,7 @@ module Gitlab
# add_key("key-42", "sha-rsa ...") # add_key("key-42", "sha-rsa ...")
# #
def add_key(key_id, key_content) def add_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"") system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
end end
   
# Remove ssh key from gitlab shell # Remove ssh key from gitlab shell
Loading
@@ -50,11 +50,16 @@ module Gitlab
Loading
@@ -50,11 +50,16 @@ module Gitlab
# remove_key("key-342", "sha-rsa ...") # remove_key("key-342", "sha-rsa ...")
# #
def remove_key(key_id, key_content) def remove_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
end end
   
def url_to_repo path def url_to_repo path
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
end end
def gitlab_shell_user_home
File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
end
end end
end end
Loading
@@ -25,12 +25,13 @@ namespace :gitlab do
Loading
@@ -25,12 +25,13 @@ namespace :gitlab do
def setup def setup
warn_user_is_not_gitlab warn_user_is_not_gitlab
   
gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
puts "This will rebuild an authorized_keys file." puts "This will rebuild an authorized_keys file."
puts "You will lose any data stored in /home/git/.ssh/authorized_keys." puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
ask_to_continue ask_to_continue
puts "" puts ""
   
system("echo '# Managed by gitlab-shell' > /home/git/.ssh/authorized_keys") system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
   
Key.find_each(batch_size: 1000) do |key| Key.find_each(batch_size: 1000) do |key|
if Gitlab::Shell.new.add_key(key.shell_id, key.key) if Gitlab::Shell.new.add_key(key.shell_id, key.key)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment