2013-02-07 09:06:39 +01:00
|
|
|
namespace :gitlab do
|
|
|
|
namespace :shell do
|
|
|
|
desc "GITLAB | Setup gitlab-shell"
|
2013-02-09 11:30:49 +01:00
|
|
|
task setup: :environment do
|
2013-02-07 09:06:39 +01:00
|
|
|
setup
|
|
|
|
end
|
2013-02-09 11:30:49 +01:00
|
|
|
|
|
|
|
desc "GITLAB | Build missing projects"
|
|
|
|
task build_missing_projects: :environment do
|
|
|
|
Project.find_each(batch_size: 1000) do |project|
|
2013-02-11 18:16:59 +01:00
|
|
|
path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
|
2013-02-09 11:30:49 +01:00
|
|
|
if File.exists?(path_to_repo)
|
|
|
|
print '-'
|
|
|
|
else
|
|
|
|
if Gitlab::Shell.new.add_repository(project.path_with_namespace)
|
|
|
|
print '.'
|
|
|
|
else
|
|
|
|
print 'F'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-02-07 09:06:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2013-02-15 00:10:18 +01:00
|
|
|
gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
|
2013-02-07 09:06:39 +01:00
|
|
|
puts "This will rebuild an authorized_keys file."
|
2013-02-15 00:10:18 +01:00
|
|
|
puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
|
2013-02-07 09:06:39 +01:00
|
|
|
ask_to_continue
|
|
|
|
puts ""
|
|
|
|
|
2013-02-15 00:10:18 +01:00
|
|
|
system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
|
2013-02-07 09:06:39 +01:00
|
|
|
|
2013-02-09 11:30:49 +01:00
|
|
|
Key.find_each(batch_size: 1000) do |key|
|
2013-02-07 09:06:39 +01:00
|
|
|
if Gitlab::Shell.new.add_key(key.shell_id, key.key)
|
|
|
|
print '.'
|
|
|
|
else
|
|
|
|
print 'F'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Gitlab::TaskAbortedByUserError
|
|
|
|
puts "Quitting...".red
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|