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 290 end
291 291  
292 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 296 if run_and_match("id -rnG", /\Wgit\W/)
296 297 puts "yes".green
297 298 else
298 299 puts "no".red
299 300 try_fixing_it(
300   - "sudo usermod -a -G git gitlab"
  301 + "sudo usermod -a -G #{gitolite_ssh_user} gitlab"
301 302 )
302 303 for_more_information(
303 304 see_installation_guide_section "System Users"
... ... @@ -308,7 +309,8 @@ namespace :gitlab do
308 309  
309 310 # see https://github.com/gitlabhq/gitlabhq/issues/1059
310 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 315 profile_file = File.expand_path("~#{Gitlab.config.ssh_user}/.profile")
314 316  
... ... @@ -510,22 +512,23 @@ namespace :gitlab do
510 512 end
511 513  
512 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 519 unless File.exists?(gitolite_config_path)
517 520 puts "can't check because of previous errors".magenta
518 521 return
519 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 526 puts "yes".green
524 527 else
525 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 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 533 for_more_information(
531 534 see_installation_guide_section "Gitolite"
... ... @@ -614,6 +617,7 @@ namespace :gitlab do
614 617 hook_file = "post-receive"
615 618 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
616 619 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
  620 + gitolite_ssh_user = Gitlab.config.ssh_user
617 621  
618 622 gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
619 623  
... ... @@ -622,7 +626,7 @@ namespace :gitlab do
622 626 else
623 627 puts "no".red
624 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 631 for_more_information(
628 632 see_installation_guide_section "Setup GitLab Hooks"
... ... @@ -638,6 +642,7 @@ namespace :gitlab do
638 642 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
639 643 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
640 644 gitolite_hook_content = File.read(gitolite_hook_file)
  645 + gitolite_ssh_user = Gitlab.config.ssh_user
641 646  
642 647 unless File.exists?(gitolite_hook_file)
643 648 puts "can't check because of previous errors".magenta
... ... @@ -652,7 +657,7 @@ namespace :gitlab do
652 657 else
653 658 puts "no".red
654 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 662 for_more_information(
658 663 see_installation_guide_section "Setup GitLab Hooks"
... ... @@ -708,7 +713,8 @@ namespace :gitlab do
708 713 end
709 714  
710 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 719 repo_base_path = Gitlab.config.git_base_path
714 720 unless File.exists?(repo_base_path)
... ... @@ -716,14 +722,14 @@ namespace :gitlab do
716 722 return
717 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 727 puts "yes".green
722 728 else
723 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 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 734 for_more_information(
729 735 see_installation_guide_section "Gitolite"
... ... @@ -773,6 +779,7 @@ namespace :gitlab do
773 779 hook_file = "post-receive"
774 780 gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common")
775 781 gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
  782 + gitolite_ssh_user = Gitlab.config.ssh_user
776 783  
777 784 unless File.exists?(gitolite_hook_file)
778 785 puts "can't check because of previous errors".magenta
... ... @@ -792,7 +799,7 @@ namespace :gitlab do
792 799 unless File.exists?(project_hook_file)
793 800 puts "missing".red
794 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 804 for_more_information(
798 805 "lib/support/rewrite-hooks.sh"
... ... @@ -806,7 +813,7 @@ namespace :gitlab do
806 813 else
807 814 puts "not a link to Gitolite's hook".red
808 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 818 for_more_information(
812 819 "lib/support/rewrite-hooks.sh"
... ... @@ -860,7 +867,6 @@ namespace :gitlab do
860 867 puts "yes".green
861 868 else
862 869 puts "no".red
863   - puts "#{repo_base_path} is not owned by git".red
864 870 try_fixing_it(
865 871 "sudo service gitlab restart",
866 872 "or",
... ...