summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/check.rake93
-rw-r--r--lib/tasks/gitlab/enable_automerge.rake5
-rw-r--r--lib/tasks/gitlab/shell.rake32
3 files changed, 84 insertions, 46 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 1ca723f271a..b54e63acfbc 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -716,7 +716,7 @@ namespace :gitlab do
end
def check_repo_base_permissions
- print "Repo base access is drwsrws---? ... "
+ print "Repo base access is drwxrws---? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
unless File.exists?(repo_base_path)
@@ -724,12 +724,14 @@ namespace :gitlab do
return
end
- if File.stat(repo_base_path).mode.to_s(8).ends_with?("6770")
+ if File.stat(repo_base_path).mode.to_s(8).ends_with?("2770")
puts "yes".green
else
puts "no".red
try_fixing_it(
- "sudo chmod -R ug+rwXs,o-rwx #{repo_base_path}"
+ "sudo chmod -R ug+rwX,o-rwx #{repo_base_path}",
+ "sudo chmod -R ug-s #{repo_base_path}",
+ "find #{repo_base_path} -type d -print0 | sudo xargs -0 chmod g+s"
)
for_more_information(
see_installation_guide_section "Gitolite"
@@ -780,21 +782,25 @@ namespace :gitlab do
Project.find_each(batch_size: 100) do |project|
print "#{project.name_with_namespace.yellow} ... "
- correct_options = options.map do |name, value|
- run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value
- end
-
- if correct_options.all?
- puts "ok".green
+ if project.empty_repo?
+ puts "repository is empty".magenta
else
- puts "wrong or missing".red
- try_fixing_it(
- sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production")
- )
- for_more_information(
- "doc/raketasks/maintenance.md"
- )
- fix_and_rerun
+ correct_options = options.map do |name, value|
+ run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value
+ end
+
+ if correct_options.all?
+ puts "ok".green
+ else
+ puts "wrong or missing".red
+ try_fixing_it(
+ sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production")
+ )
+ for_more_information(
+ "doc/raketasks/maintenance.md"
+ )
+ fix_and_rerun
+ end
end
end
end
@@ -820,32 +826,37 @@ namespace :gitlab do
Project.find_each(batch_size: 100) do |project|
print "#{project.name_with_namespace.yellow} ... "
- project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file)
- unless File.exists?(project_hook_file)
- puts "missing".red
- try_fixing_it(
- "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
- )
- for_more_information(
- "lib/support/rewrite-hooks.sh"
- )
- fix_and_rerun
- next
- end
-
- if File.lstat(project_hook_file).symlink? &&
- File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
- puts "ok".green
+ if project.empty_repo?
+ puts "repository is empty".magenta
else
- puts "not a link to Gitolite's hook".red
- try_fixing_it(
- "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
- )
- for_more_information(
- "lib/support/rewrite-hooks.sh"
- )
- fix_and_rerun
+ project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file)
+
+ unless File.exists?(project_hook_file)
+ puts "missing".red
+ try_fixing_it(
+ "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
+ )
+ for_more_information(
+ "lib/support/rewrite-hooks.sh"
+ )
+ fix_and_rerun
+ next
+ end
+
+ if File.lstat(project_hook_file).symlink? &&
+ File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
+ puts "ok".green
+ else
+ puts "not a link to Gitolite's hook".red
+ try_fixing_it(
+ "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
+ )
+ for_more_information(
+ "lib/support/rewrite-hooks.sh"
+ )
+ fix_and_rerun
+ end
end
end
end
diff --git a/lib/tasks/gitlab/enable_automerge.rake b/lib/tasks/gitlab/enable_automerge.rake
index e92da81021f..a89c6eaa5c4 100644
--- a/lib/tasks/gitlab/enable_automerge.rake
+++ b/lib/tasks/gitlab/enable_automerge.rake
@@ -3,11 +3,6 @@ namespace :gitlab do
task :enable_automerge => :environment do
warn_user_is_not_gitlab
- puts "Updating repo permissions ..."
- Gitlab::Gitolite.new.enable_automerge
- puts "... #{"done".green}"
- puts ""
-
print "Creating satellites for ..."
unless Project.count > 0
puts "skipping, because you have no projects".magenta
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
new file mode 100644
index 00000000000..25713482ed8
--- /dev/null
+++ b/lib/tasks/gitlab/shell.rake
@@ -0,0 +1,32 @@
+namespace :gitlab do
+ namespace :shell do
+ desc "GITLAB | Setup gitlab-shell"
+ task :setup => :environment do
+ setup
+ end
+ end
+
+ def setup
+ warn_user_is_not_gitlab
+
+ puts "This will rebuild an authorized_keys file."
+ puts "You will lose any data stored in /home/git/.ssh/authorized_keys."
+ ask_to_continue
+ puts ""
+
+ system("echo '# Managed by gitlab-shell' > /home/git/.ssh/authorized_keys")
+
+ Key.find_each(:batch_size => 1000) do |key|
+ 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
+