Commit 8f9dec2883060b6a1610d64b9488efe7859963c8
1 parent
76329a46
Exists in
master
and in
4 other branches
Fix check.rake to use the new user and group settings
Showing
2 changed files
with
28 additions
and
19 deletions
Show diff stats
lib/tasks/gitlab/check.rake
@@ -169,7 +169,7 @@ namespace :gitlab do | @@ -169,7 +169,7 @@ namespace :gitlab do | ||
169 | else | 169 | else |
170 | puts "no".red | 170 | puts "no".red |
171 | try_fixing_it( | 171 | try_fixing_it( |
172 | - "sudo -u gitlab -H bundle exec rake db:migrate" | 172 | + sudo_gitlab("bundle exec rake db:migrate") |
173 | ) | 173 | ) |
174 | fix_and_rerun | 174 | fix_and_rerun |
175 | end | 175 | end |
@@ -194,7 +194,7 @@ namespace :gitlab do | @@ -194,7 +194,7 @@ namespace :gitlab do | ||
194 | else | 194 | else |
195 | puts "no".red | 195 | puts "no".red |
196 | try_fixing_it( | 196 | try_fixing_it( |
197 | - "sudo -u gitlab -H bundle exec rake gitlab:satellites:create", | 197 | + sudo_gitlab("bundle exec rake gitlab:satellites:create"), |
198 | "If necessary, remove the tmp/repo_satellites directory ...", | 198 | "If necessary, remove the tmp/repo_satellites directory ...", |
199 | "... and rerun the above command" | 199 | "... and rerun the above command" |
200 | ) | 200 | ) |
@@ -269,7 +269,8 @@ namespace :gitlab do | @@ -269,7 +269,8 @@ namespace :gitlab do | ||
269 | ######################## | 269 | ######################## |
270 | 270 | ||
271 | def check_gitlab_git_config | 271 | def check_gitlab_git_config |
272 | - print "Git configured for gitlab user? ... " | 272 | + gitlab_user = Gitlab.config.gitlab.user |
273 | + print "Git configured for #{gitlab_user} user? ... " | ||
273 | 274 | ||
274 | options = { | 275 | options = { |
275 | "user.name" => "GitLab", | 276 | "user.name" => "GitLab", |
@@ -284,8 +285,8 @@ namespace :gitlab do | @@ -284,8 +285,8 @@ namespace :gitlab do | ||
284 | else | 285 | else |
285 | puts "no".red | 286 | puts "no".red |
286 | try_fixing_it( | 287 | try_fixing_it( |
287 | - "sudo -u gitlab -H git config --global user.name \"#{options["user.name"]}\"", | ||
288 | - "sudo -u gitlab -H git config --global user.email \"#{options["user.email"]}\"" | 288 | + sudo_gitlab("git config --global user.name \"#{options["user.name"]}\""), |
289 | + sudo_gitlab("git config --global user.email \"#{options["user.email"]}\"") | ||
289 | ) | 290 | ) |
290 | for_more_information( | 291 | for_more_information( |
291 | see_installation_guide_section "GitLab" | 292 | see_installation_guide_section "GitLab" |
@@ -296,15 +297,15 @@ namespace :gitlab do | @@ -296,15 +297,15 @@ namespace :gitlab do | ||
296 | 297 | ||
297 | def check_gitlab_in_git_group | 298 | def check_gitlab_in_git_group |
298 | gitlab_user = Gitlab.config.gitlab.user | 299 | gitlab_user = Gitlab.config.gitlab.user |
299 | - gitolite_group = Gitlab.config.gitolite.group | ||
300 | - print "gitlab user '#{gitlab_user}' has git group '#{gitolite_group}'? ... " | 300 | + gitolite_owner_group = Gitlab.config.gitolite.owner_group |
301 | + print "#{gitlab_user} user is in #{gitolite_owner_group} group? ... " | ||
301 | 302 | ||
302 | - if run_and_match("id -rnG", /^#{gitolite_group}\W|\W#{gitolite_group}\W|\W#{gitolite_group}$/) | 303 | + if run_and_match("id -rnG", /^#{gitolite_owner_group}\W|\W#{gitolite_owner_group}\W|\W#{gitolite_owner_group}$/) |
303 | puts "yes".green | 304 | puts "yes".green |
304 | else | 305 | else |
305 | puts "no".red | 306 | puts "no".red |
306 | try_fixing_it( | 307 | try_fixing_it( |
307 | - "sudo usermod -a -G #{gitolite_group} #{gitlab_user}" | 308 | + "sudo usermod -a -G #{gitolite_owner_group} #{gitlab_user}" |
308 | ) | 309 | ) |
309 | for_more_information( | 310 | for_more_information( |
310 | see_installation_guide_section "System Users" | 311 | see_installation_guide_section "System Users" |
@@ -519,7 +520,8 @@ namespace :gitlab do | @@ -519,7 +520,8 @@ namespace :gitlab do | ||
519 | 520 | ||
520 | def check_dot_gitolite_user_and_group | 521 | def check_dot_gitolite_user_and_group |
521 | gitolite_ssh_user = Gitlab.config.gitolite.ssh_user | 522 | gitolite_ssh_user = Gitlab.config.gitolite.ssh_user |
522 | - print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... " | 523 | + gitolite_owner_group = Gitlab.config.gitolite.owner_group |
524 | + print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_owner_group} ... " | ||
523 | 525 | ||
524 | gitolite_config_path = File.join(gitolite_user_home, ".gitolite") | 526 | gitolite_config_path = File.join(gitolite_user_home, ".gitolite") |
525 | unless File.exists?(gitolite_config_path) | 527 | unless File.exists?(gitolite_config_path) |
@@ -528,12 +530,12 @@ namespace :gitlab do | @@ -528,12 +530,12 @@ namespace :gitlab do | ||
528 | end | 530 | end |
529 | 531 | ||
530 | if File.stat(gitolite_config_path).uid == uid_for(gitolite_ssh_user) && | 532 | if File.stat(gitolite_config_path).uid == uid_for(gitolite_ssh_user) && |
531 | - File.stat(gitolite_config_path).gid == gid_for(gitolite_ssh_user) | 533 | + File.stat(gitolite_config_path).gid == gid_for(gitolite_owner_group) |
532 | puts "yes".green | 534 | puts "yes".green |
533 | else | 535 | else |
534 | puts "no".red | 536 | puts "no".red |
535 | try_fixing_it( | 537 | try_fixing_it( |
536 | - "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{gitolite_config_path}" | 538 | + "sudo chown -R #{gitolite_ssh_user}:#{gitolite_owner_group} #{gitolite_config_path}" |
537 | ) | 539 | ) |
538 | for_more_information( | 540 | for_more_information( |
539 | see_installation_guide_section "Gitolite" | 541 | see_installation_guide_section "Gitolite" |
@@ -738,7 +740,8 @@ namespace :gitlab do | @@ -738,7 +740,8 @@ namespace :gitlab do | ||
738 | 740 | ||
739 | def check_repo_base_user_and_group | 741 | def check_repo_base_user_and_group |
740 | gitolite_ssh_user = Gitlab.config.gitolite.ssh_user | 742 | gitolite_ssh_user = Gitlab.config.gitolite.ssh_user |
741 | - print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_ssh_user}? ... " | 743 | + gitolite_owner_group = Gitlab.config.gitolite.owner_group |
744 | + print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_owner_group}? ... " | ||
742 | 745 | ||
743 | repo_base_path = Gitlab.config.gitolite.repos_path | 746 | repo_base_path = Gitlab.config.gitolite.repos_path |
744 | unless File.exists?(repo_base_path) | 747 | unless File.exists?(repo_base_path) |
@@ -747,12 +750,12 @@ namespace :gitlab do | @@ -747,12 +750,12 @@ namespace :gitlab do | ||
747 | end | 750 | end |
748 | 751 | ||
749 | if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) && | 752 | if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) && |
750 | - File.stat(repo_base_path).gid == gid_for(gitolite_ssh_user) | 753 | + File.stat(repo_base_path).gid == gid_for(gitolite_owner_group) |
751 | puts "yes".green | 754 | puts "yes".green |
752 | else | 755 | else |
753 | puts "no".red | 756 | puts "no".red |
754 | try_fixing_it( | 757 | try_fixing_it( |
755 | - "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{repo_base_path}" | 758 | + "sudo chown -R #{gitolite_ssh_user}:#{gitolite_owner_group} #{repo_base_path}" |
756 | ) | 759 | ) |
757 | for_more_information( | 760 | for_more_information( |
758 | see_installation_guide_section "Gitolite" | 761 | see_installation_guide_section "Gitolite" |
@@ -786,7 +789,7 @@ namespace :gitlab do | @@ -786,7 +789,7 @@ namespace :gitlab do | ||
786 | else | 789 | else |
787 | puts "wrong or missing".red | 790 | puts "wrong or missing".red |
788 | try_fixing_it( | 791 | try_fixing_it( |
789 | - "sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos" | 792 | + sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos") |
790 | ) | 793 | ) |
791 | for_more_information( | 794 | for_more_information( |
792 | "doc/raketasks/maintenance.md" | 795 | "doc/raketasks/maintenance.md" |
@@ -892,7 +895,7 @@ namespace :gitlab do | @@ -892,7 +895,7 @@ namespace :gitlab do | ||
892 | else | 895 | else |
893 | puts "no".red | 896 | puts "no".red |
894 | try_fixing_it( | 897 | try_fixing_it( |
895 | - "sudo -u gitlab -H bundle exec rake sidekiq:start" | 898 | + sudo_gitlab("bundle exec rake sidekiq:start") |
896 | ) | 899 | ) |
897 | for_more_information( | 900 | for_more_information( |
898 | see_installation_guide_section("Install Init Script"), | 901 | see_installation_guide_section("Install Init Script"), |
@@ -934,6 +937,11 @@ namespace :gitlab do | @@ -934,6 +937,11 @@ namespace :gitlab do | ||
934 | "doc/install/installation.md in section \"#{section}\"" | 937 | "doc/install/installation.md in section \"#{section}\"" |
935 | end | 938 | end |
936 | 939 | ||
940 | + def sudo_gitlab(command) | ||
941 | + gitlab_user = Gitlab.config.gitlab.user | ||
942 | + "sudo -u #{gitlab_user} -H #{command}" | ||
943 | + end | ||
944 | + | ||
937 | def start_checking(component) | 945 | def start_checking(component) |
938 | puts "Checking #{component.yellow} ..." | 946 | puts "Checking #{component.yellow} ..." |
939 | puts "" | 947 | puts "" |
lib/tasks/gitlab/task_helpers.rake
@@ -56,12 +56,13 @@ namespace :gitlab do | @@ -56,12 +56,13 @@ namespace :gitlab do | ||
56 | 56 | ||
57 | def warn_user_is_not_gitlab | 57 | def warn_user_is_not_gitlab |
58 | unless @warned_user_not_gitlab | 58 | unless @warned_user_not_gitlab |
59 | + gitlab_user = Gitlab.config.gitlab.user | ||
59 | current_user = run("whoami").chomp | 60 | current_user = run("whoami").chomp |
60 | - unless current_user == "gitlab" | 61 | + unless current_user == gitlab_user |
61 | puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}" | 62 | puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}" |
62 | puts " You are running as user #{current_user.magenta}, we hope you know what you are doing." | 63 | puts " You are running as user #{current_user.magenta}, we hope you know what you are doing." |
63 | puts " Things may work\/fail for the wrong reasons." | 64 | puts " Things may work\/fail for the wrong reasons." |
64 | - puts " For correct results you should run this as user #{"gitlab".magenta}." | 65 | + puts " For correct results you should run this as user #{gitlab_user.magenta}." |
65 | puts "" | 66 | puts "" |
66 | end | 67 | end |
67 | @warned_user_not_gitlab = true | 68 | @warned_user_not_gitlab = true |