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 | 169 | else |
170 | 170 | puts "no".red |
171 | 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 | 174 | fix_and_rerun |
175 | 175 | end |
... | ... | @@ -194,7 +194,7 @@ namespace :gitlab do |
194 | 194 | else |
195 | 195 | puts "no".red |
196 | 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 | 198 | "If necessary, remove the tmp/repo_satellites directory ...", |
199 | 199 | "... and rerun the above command" |
200 | 200 | ) |
... | ... | @@ -269,7 +269,8 @@ namespace :gitlab do |
269 | 269 | ######################## |
270 | 270 | |
271 | 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 | 275 | options = { |
275 | 276 | "user.name" => "GitLab", |
... | ... | @@ -284,8 +285,8 @@ namespace :gitlab do |
284 | 285 | else |
285 | 286 | puts "no".red |
286 | 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 | 291 | for_more_information( |
291 | 292 | see_installation_guide_section "GitLab" |
... | ... | @@ -296,15 +297,15 @@ namespace :gitlab do |
296 | 297 | |
297 | 298 | def check_gitlab_in_git_group |
298 | 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 | 304 | puts "yes".green |
304 | 305 | else |
305 | 306 | puts "no".red |
306 | 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 | 310 | for_more_information( |
310 | 311 | see_installation_guide_section "System Users" |
... | ... | @@ -519,7 +520,8 @@ namespace :gitlab do |
519 | 520 | |
520 | 521 | def check_dot_gitolite_user_and_group |
521 | 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 | 526 | gitolite_config_path = File.join(gitolite_user_home, ".gitolite") |
525 | 527 | unless File.exists?(gitolite_config_path) |
... | ... | @@ -528,12 +530,12 @@ namespace :gitlab do |
528 | 530 | end |
529 | 531 | |
530 | 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 | 534 | puts "yes".green |
533 | 535 | else |
534 | 536 | puts "no".red |
535 | 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 | 540 | for_more_information( |
539 | 541 | see_installation_guide_section "Gitolite" |
... | ... | @@ -738,7 +740,8 @@ namespace :gitlab do |
738 | 740 | |
739 | 741 | def check_repo_base_user_and_group |
740 | 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 | 746 | repo_base_path = Gitlab.config.gitolite.repos_path |
744 | 747 | unless File.exists?(repo_base_path) |
... | ... | @@ -747,12 +750,12 @@ namespace :gitlab do |
747 | 750 | end |
748 | 751 | |
749 | 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 | 754 | puts "yes".green |
752 | 755 | else |
753 | 756 | puts "no".red |
754 | 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 | 760 | for_more_information( |
758 | 761 | see_installation_guide_section "Gitolite" |
... | ... | @@ -786,7 +789,7 @@ namespace :gitlab do |
786 | 789 | else |
787 | 790 | puts "wrong or missing".red |
788 | 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 | 794 | for_more_information( |
792 | 795 | "doc/raketasks/maintenance.md" |
... | ... | @@ -892,7 +895,7 @@ namespace :gitlab do |
892 | 895 | else |
893 | 896 | puts "no".red |
894 | 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 | 900 | for_more_information( |
898 | 901 | see_installation_guide_section("Install Init Script"), |
... | ... | @@ -934,6 +937,11 @@ namespace :gitlab do |
934 | 937 | "doc/install/installation.md in section \"#{section}\"" |
935 | 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 | 945 | def start_checking(component) |
938 | 946 | puts "Checking #{component.yellow} ..." |
939 | 947 | puts "" | ... | ... |
lib/tasks/gitlab/task_helpers.rake
... | ... | @@ -56,12 +56,13 @@ namespace :gitlab do |
56 | 56 | |
57 | 57 | def warn_user_is_not_gitlab |
58 | 58 | unless @warned_user_not_gitlab |
59 | + gitlab_user = Gitlab.config.gitlab.user | |
59 | 60 | current_user = run("whoami").chomp |
60 | - unless current_user == "gitlab" | |
61 | + unless current_user == gitlab_user | |
61 | 62 | puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}" |
62 | 63 | puts " You are running as user #{current_user.magenta}, we hope you know what you are doing." |
63 | 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 | 66 | puts "" |
66 | 67 | end |
67 | 68 | @warned_user_not_gitlab = true | ... | ... |