diff options
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/check.rake | 56 | ||||
-rw-r--r-- | lib/tasks/gitlab/enable_automerge.rake | 39 |
2 files changed, 95 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 8acb6a7fd19..badb47c6779 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -25,6 +25,7 @@ namespace :gitlab do check_init_script_exists check_init_script_up_to_date check_projects_have_namespace + check_satellites_exist check_redis_version check_ruby_version check_git_version @@ -237,6 +238,37 @@ namespace :gitlab do end end + def check_satellites_exist + print "Projects have satellites? ... " + + unless Project.count > 0 + puts "can't check, you have no projects".magenta + return + end + puts "" + + Project.find_each(batch_size: 100) do |project| + print sanitized_message(project) + + if project.satellite.exists? + puts "yes".green + elsif project.empty_repo? + puts "can't create, repository is empty".magenta + else + puts "no".red + try_fixing_it( + sudo_gitlab("bundle exec rake gitlab:satellites:create RAILS_ENV=production"), + "If necessary, remove the tmp/repo_satellites directory ...", + "... and rerun the above command" + ) + for_more_information( + "doc/raketasks/maintenance.md " + ) + fix_and_rerun + end + end + end + def check_log_writable print "Log directory writable? ... " @@ -307,6 +339,7 @@ namespace :gitlab do check_repo_base_is_not_symlink check_repo_base_user_and_group check_repo_base_permissions + check_satellites_permissions check_repos_hooks_directory_is_link check_gitlab_shell_self_test @@ -384,6 +417,29 @@ namespace :gitlab do end end + def check_satellites_permissions + print "Satellites access is drwxr-x---? ... " + + satellites_path = Gitlab.config.satellites.path + unless File.exists?(satellites_path) + puts "can't check because of previous errors".magenta + return + end + + if File.stat(satellites_path).mode.to_s(8).ends_with?("0750") + puts "yes".green + else + puts "no".red + try_fixing_it( + "sudo chmod u+rwx,g=rx,o-rwx #{satellites_path}", + ) + for_more_information( + see_installation_guide_section "GitLab" + ) + fix_and_rerun + end + end + def check_repo_base_user_and_group gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user gitlab_shell_owner_group = Gitlab.config.gitlab_shell.owner_group diff --git a/lib/tasks/gitlab/enable_automerge.rake b/lib/tasks/gitlab/enable_automerge.rake new file mode 100644 index 00000000000..3dade9d75b8 --- /dev/null +++ b/lib/tasks/gitlab/enable_automerge.rake @@ -0,0 +1,39 @@ +namespace :gitlab do + namespace :satellites do + desc "GitLab | Create satellite repos" + task create: :environment do + create_satellites + end + end + + def create_satellites + warn_user_is_not_gitlab + + print "Creating satellites for ..." + unless Project.count > 0 + puts "skipping, because you have no projects".magenta + return + end + puts "" + + Project.find_each(batch_size: 100) do |project| + print "#{project.name_with_namespace.yellow} ... " + + unless project.repo_exists? + puts "skipping, because the repo is empty".magenta + next + end + + if project.satellite.exists? + puts "exists already".green + else + print "\n... " + if project.satellite.create + puts "created".green + else + puts "error".red + end + end + end + end +end |