2013-02-07 03:06:39 -05:00
|
|
|
namespace :gitlab do
|
|
|
|
namespace :shell do
|
|
|
|
desc "GITLAB | Setup gitlab-shell"
|
2013-02-09 05:30:49 -05:00
|
|
|
task setup: :environment do
|
2013-02-07 03:06:39 -05:00
|
|
|
setup
|
|
|
|
end
|
2013-02-09 05:30:49 -05:00
|
|
|
|
|
|
|
desc "GITLAB | Build missing projects"
|
|
|
|
task build_missing_projects: :environment do
|
|
|
|
Project.find_each(batch_size: 1000) do |project|
|
2013-02-11 12:16:59 -05:00
|
|
|
path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
|
2013-02-09 05:30:49 -05: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 03:06:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
2013-05-29 15:19:23 -04:00
|
|
|
unless ENV['force'] == 'yes'
|
|
|
|
puts "This will rebuild an authorized_keys file."
|
2013-07-18 06:55:01 -04:00
|
|
|
puts "You will lose any data stored in authorized_keys file."
|
2013-05-29 15:19:23 -04:00
|
|
|
ask_to_continue
|
|
|
|
puts ""
|
|
|
|
end
|
2013-02-07 03:06:39 -05:00
|
|
|
|
2013-07-18 06:55:01 -04:00
|
|
|
Gitlab::Shell.new.remove_all_keys
|
2013-02-07 03:06:39 -05:00
|
|
|
|
2014-03-13 13:32:30 -04:00
|
|
|
Gitlab::Shell.new.batch_add_keys do |adder|
|
|
|
|
Key.find_each(batch_size: 1000) do |key|
|
|
|
|
adder.add_key(key.shell_id, key.key)
|
2013-02-07 03:06:39 -05:00
|
|
|
print '.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-13 13:32:30 -04:00
|
|
|
unless $?.success?
|
|
|
|
puts "Failed to add keys...".red
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2013-02-07 03:06:39 -05:00
|
|
|
rescue Gitlab::TaskAbortedByUserError
|
|
|
|
puts "Quitting...".red
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|