Commit 69c18903e710ceec9aa577312835f5b70029f208

Authored by Riyad Preukschas
1 parent 190e483f

Update gitlab:check task to use the Gitlab.config.ssh_user setting

Showing 1 changed file with 25 additions and 19 deletions   Show diff stats
lib/tasks/gitlab/check.rake
@@ -290,14 +290,15 @@ namespace :gitlab do @@ -290,14 +290,15 @@ namespace :gitlab do
290 end 290 end
291 291
292 def check_gitlab_in_git_group 292 def check_gitlab_in_git_group
293 - print "gitlab user is in git group? ... " 293 + gitolite_ssh_user = Gitlab.config.ssh_user
  294 + print "gitlab user is in #{gitolite_ssh_user} group? ... "
294 295
295 if run_and_match("id -rnG", /\Wgit\W/) 296 if run_and_match("id -rnG", /\Wgit\W/)
296 puts "yes".green 297 puts "yes".green
297 else 298 else
298 puts "no".red 299 puts "no".red
299 try_fixing_it( 300 try_fixing_it(
300 - "sudo usermod -a -G git gitlab" 301 + "sudo usermod -a -G #{gitolite_ssh_user} gitlab"
301 ) 302 )
302 for_more_information( 303 for_more_information(
303 see_installation_guide_section "System Users" 304 see_installation_guide_section "System Users"
@@ -308,7 +309,8 @@ namespace :gitlab do @@ -308,7 +309,8 @@ namespace :gitlab do
308 309
309 # see https://github.com/gitlabhq/gitlabhq/issues/1059 310 # see https://github.com/gitlabhq/gitlabhq/issues/1059
310 def check_issue_1056_shell_profile_error 311 def check_issue_1056_shell_profile_error
311 - print "Has no \"-e\" in ~git/.profile ... " 312 + gitolite_ssh_user = Gitlab.config.ssh_user
  313 + print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
312 314
313 profile_file = File.expand_path("~#{Gitlab.config.ssh_user}/.profile") 315 profile_file = File.expand_path("~#{Gitlab.config.ssh_user}/.profile")
314 316
@@ -510,22 +512,23 @@ namespace :gitlab do @@ -510,22 +512,23 @@ namespace :gitlab do
510 end 512 end
511 513
512 def check_dot_gitolite_user_and_group 514 def check_dot_gitolite_user_and_group
513 - print "Config directory owned by git:git? ... " 515 + gitolite_ssh_user = Gitlab.config.ssh_user
  516 + print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... "
514 517
515 - gitolite_config_path = File.expand_path("~#{Gitlab.config.ssh_user}/.gitolite") 518 + gitolite_config_path = File.expand_path("~#{gitolite_ssh_user}/.gitolite")
516 unless File.exists?(gitolite_config_path) 519 unless File.exists?(gitolite_config_path)
517 puts "can't check because of previous errors".magenta 520 puts "can't check because of previous errors".magenta
518 return 521 return
519 end 522 end
520 523
521 - if `stat --printf %U #{gitolite_config_path}` == "git" && # user  
522 - `stat --printf %G #{gitolite_config_path}` == "git" #group 524 + if `stat --printf %U #{gitolite_config_path}` == gitolite_ssh_user && # user
  525 + `stat --printf %G #{gitolite_config_path}` == gitolite_ssh_user #group
523 puts "yes".green 526 puts "yes".green
524 else 527 else
525 puts "no".red 528 puts "no".red
526 - puts "#{gitolite_config_path} is not owned by git".red 529 + puts "#{gitolite_config_path} is not owned by #{gitolite_ssh_user}".red
527 try_fixing_it( 530 try_fixing_it(
528 - "sudo chown -R git:git #{gitolite_config_path}" 531 + "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{gitolite_config_path}"
529 ) 532 )
530 for_more_information( 533 for_more_information(
531 see_installation_guide_section "Gitolite" 534 see_installation_guide_section "Gitolite"
@@ -614,6 +617,7 @@ namespace :gitlab do @@ -614,6 +617,7 @@ namespace :gitlab do
614 hook_file = "post-receive" 617 hook_file = "post-receive"
615 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") 618 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
616 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 619 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
  620 + gitolite_ssh_user = Gitlab.config.ssh_user
617 621
618 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file) 622 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
619 623
@@ -622,7 +626,7 @@ namespace :gitlab do @@ -622,7 +626,7 @@ namespace :gitlab do
622 else 626 else
623 puts "no".red 627 puts "no".red
624 try_fixing_it( 628 try_fixing_it(
625 - "sudo -u git cp #{gitlab_hook_file} #{gitolite_hook_file}" 629 + "sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}"
626 ) 630 )
627 for_more_information( 631 for_more_information(
628 see_installation_guide_section "Setup GitLab Hooks" 632 see_installation_guide_section "Setup GitLab Hooks"
@@ -638,6 +642,7 @@ namespace :gitlab do @@ -638,6 +642,7 @@ namespace :gitlab do
638 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") 642 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
639 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 643 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
640 gitolite_hook_content = File.read(gitolite_hook_file) 644 gitolite_hook_content = File.read(gitolite_hook_file)
  645 + gitolite_ssh_user = Gitlab.config.ssh_user
641 646
642 unless File.exists?(gitolite_hook_file) 647 unless File.exists?(gitolite_hook_file)
643 puts "can't check because of previous errors".magenta 648 puts "can't check because of previous errors".magenta
@@ -652,7 +657,7 @@ namespace :gitlab do @@ -652,7 +657,7 @@ namespace :gitlab do
652 else 657 else
653 puts "no".red 658 puts "no".red
654 try_fixing_it( 659 try_fixing_it(
655 - "sudo -u git cp #{gitlab_hook_file} #{gitolite_hook_file}" 660 + "sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}"
656 ) 661 )
657 for_more_information( 662 for_more_information(
658 see_installation_guide_section "Setup GitLab Hooks" 663 see_installation_guide_section "Setup GitLab Hooks"
@@ -708,7 +713,8 @@ namespace :gitlab do @@ -708,7 +713,8 @@ namespace :gitlab do
708 end 713 end
709 714
710 def check_repo_base_user_and_group 715 def check_repo_base_user_and_group
711 - print "Repo base owned by git:git? ... " 716 + gitolite_ssh_user = Gitlab.config.ssh_user
  717 + print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_ssh_user}? ... "
712 718
713 repo_base_path = Gitlab.config.git_base_path 719 repo_base_path = Gitlab.config.git_base_path
714 unless File.exists?(repo_base_path) 720 unless File.exists?(repo_base_path)
@@ -716,14 +722,14 @@ namespace :gitlab do @@ -716,14 +722,14 @@ namespace :gitlab do
716 return 722 return
717 end 723 end
718 724
719 - if `stat --printf %U #{repo_base_path}` == "git" && # user  
720 - `stat --printf %G #{repo_base_path}` == "git" #group 725 + if `stat --printf %U #{repo_base_path}` == gitolite_ssh_user && # user
  726 + `stat --printf %G #{repo_base_path}` == gitolite_ssh_user #group
721 puts "yes".green 727 puts "yes".green
722 else 728 else
723 puts "no".red 729 puts "no".red
724 - puts "#{repo_base_path} is not owned by git".red 730 + puts "#{repo_base_path} is not owned by #{gitolite_ssh_user}".red
725 try_fixing_it( 731 try_fixing_it(
726 - "sudo chown -R git:git #{repo_base_path}" 732 + "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{repo_base_path}"
727 ) 733 )
728 for_more_information( 734 for_more_information(
729 see_installation_guide_section "Gitolite" 735 see_installation_guide_section "Gitolite"
@@ -773,6 +779,7 @@ namespace :gitlab do @@ -773,6 +779,7 @@ namespace :gitlab do
773 hook_file = "post-receive" 779 hook_file = "post-receive"
774 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") 780 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
775 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file) 781 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
  782 + gitolite_ssh_user = Gitlab.config.ssh_user
776 783
777 unless File.exists?(gitolite_hook_file) 784 unless File.exists?(gitolite_hook_file)
778 puts "can't check because of previous errors".magenta 785 puts "can't check because of previous errors".magenta
@@ -792,7 +799,7 @@ namespace :gitlab do @@ -792,7 +799,7 @@ namespace :gitlab do
792 unless File.exists?(project_hook_file) 799 unless File.exists?(project_hook_file)
793 puts "missing".red 800 puts "missing".red
794 try_fixing_it( 801 try_fixing_it(
795 - "sudo -u git ln -sf #{gitolite_hook_file} #{project_hook_file}" 802 + "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
796 ) 803 )
797 for_more_information( 804 for_more_information(
798 "lib/support/rewrite-hooks.sh" 805 "lib/support/rewrite-hooks.sh"
@@ -806,7 +813,7 @@ namespace :gitlab do @@ -806,7 +813,7 @@ namespace :gitlab do
806 else 813 else
807 puts "not a link to Gitolite's hook".red 814 puts "not a link to Gitolite's hook".red
808 try_fixing_it( 815 try_fixing_it(
809 - "sudo -u git ln -sf #{gitolite_hook_file} #{project_hook_file}" 816 + "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
810 ) 817 )
811 for_more_information( 818 for_more_information(
812 "lib/support/rewrite-hooks.sh" 819 "lib/support/rewrite-hooks.sh"
@@ -860,7 +867,6 @@ namespace :gitlab do @@ -860,7 +867,6 @@ namespace :gitlab do
860 puts "yes".green 867 puts "yes".green
861 else 868 else
862 puts "no".red 869 puts "no".red
863 - puts "#{repo_base_path} is not owned by git".red  
864 try_fixing_it( 870 try_fixing_it(
865 "sudo service gitlab restart", 871 "sudo service gitlab restart",
866 "or", 872 "or",