Backport fixes to the check and info tasks

This commit is contained in:
Riyad Preukschas 2013-01-07 21:32:29 +01:00
parent 10b312abad
commit 0e2880b740
4 changed files with 101 additions and 100 deletions

View file

@ -89,6 +89,7 @@ backup:
## Gitolite settings ## Gitolite settings
gitolite: gitolite:
admin_uri: git@localhost:gitolite-admin admin_uri: git@localhost:gitolite-admin
# repos_path must not be a symlink
repos_path: /home/git/repositories/ repos_path: /home/git/repositories/
hooks_path: /home/git/.gitolite/hooks/ hooks_path: /home/git/.gitolite/hooks/
admin_key: gitlab admin_key: gitlab

View file

@ -48,7 +48,7 @@ namespace :gitlab do
see_database_guide, see_database_guide,
"http://guides.rubyonrails.org/getting_started.html#configuring-a-database" "http://guides.rubyonrails.org/getting_started.html#configuring-a-database"
) )
check_failed fix_and_rerun
end end
end end
@ -65,7 +65,7 @@ namespace :gitlab do
"https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL", "https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL",
see_database_guide see_database_guide
) )
check_failed fix_and_rerun
end end
end end
@ -85,7 +85,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "GitLab" see_installation_guide_section "GitLab"
) )
check_failed fix_and_rerun
end end
end end
@ -98,7 +98,7 @@ namespace :gitlab do
end end
# omniauth or ldap could have been deleted from the file # omniauth or ldap could have been deleted from the file
unless Gitlab.config.pre_40_config unless Gitlab.config['git_host']
puts "no".green puts "no".green
else else
puts "yes".red puts "yes".red
@ -110,7 +110,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "GitLab" see_installation_guide_section "GitLab"
) )
check_failed fix_and_rerun
end end
end end
@ -129,7 +129,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Install Init Script" see_installation_guide_section "Install Init Script"
) )
check_failed fix_and_rerun
end end
end end
@ -155,7 +155,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Install Init Script" see_installation_guide_section "Install Init Script"
) )
check_failed fix_and_rerun
end end
end end
@ -171,7 +171,7 @@ namespace :gitlab do
try_fixing_it( try_fixing_it(
"sudo -u gitlab -H bundle exec rake db:migrate" "sudo -u gitlab -H bundle exec rake db:migrate"
) )
check_failed fix_and_rerun
end end
end end
@ -201,7 +201,7 @@ namespace :gitlab do
for_more_information( for_more_information(
"doc/raketasks/maintenance.md " "doc/raketasks/maintenance.md "
) )
check_failed fix_and_rerun
end end
end end
end end
@ -222,7 +222,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "GitLab" see_installation_guide_section "GitLab"
) )
check_failed fix_and_rerun
end end
end end
@ -242,7 +242,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "GitLab" see_installation_guide_section "GitLab"
) )
check_failed fix_and_rerun
end end
end end
end end
@ -256,7 +256,7 @@ namespace :gitlab do
start_checking "Environment" start_checking "Environment"
check_gitlab_in_git_group check_gitlab_in_git_group
check_issue_1056_shell_profile_error check_issue_1059_shell_profile_error
check_gitlab_git_config check_gitlab_git_config
check_python2_exists check_python2_exists
check_python2_version check_python2_version
@ -290,7 +290,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "GitLab" see_installation_guide_section "GitLab"
) )
check_failed fix_and_rerun
end end
end end
@ -308,12 +308,12 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "System Users" see_installation_guide_section "System Users"
) )
check_failed fix_and_rerun
end end
end end
# see https://github.com/gitlabhq/gitlabhq/issues/1059 # see https://github.com/gitlabhq/gitlabhq/issues/1059
def check_issue_1056_shell_profile_error def check_issue_1059_shell_profile_error
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... " print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
@ -332,7 +332,7 @@ namespace :gitlab do
see_installation_guide_section("Gitolite"), see_installation_guide_section("Gitolite"),
"https://github.com/gitlabhq/gitlabhq/issues/1059" "https://github.com/gitlabhq/gitlabhq/issues/1059"
) )
check_failed fix_and_rerun
end end
end end
@ -352,7 +352,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Packages / Dependencies" see_installation_guide_section "Packages / Dependencies"
) )
check_failed fix_and_rerun
end end
end end
@ -378,7 +378,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Packages / Dependencies" see_installation_guide_section "Packages / Dependencies"
) )
check_failed fix_and_rerun
end end
end end
end end
@ -398,6 +398,7 @@ namespace :gitlab do
check_dot_gitolite_user_and_group check_dot_gitolite_user_and_group
check_dot_gitolite_permissions check_dot_gitolite_permissions
check_repo_base_exists check_repo_base_exists
check_repo_base_is_not_symlink
check_repo_base_user_and_group check_repo_base_user_and_group
check_repo_base_permissions check_repo_base_permissions
check_can_clone_gitolite_admin check_can_clone_gitolite_admin
@ -434,7 +435,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
# assumes #check_can_clone_gitolite_admin has been run before # assumes #check_can_clone_gitolite_admin has been run before
@ -466,7 +467,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
ensure ensure
FileUtils.rm_rf("/tmp/gitolite_gitlab_test") FileUtils.rm_rf("/tmp/gitolite_gitlab_test")
end end
@ -488,7 +489,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -511,7 +512,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -537,13 +538,13 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
def check_gitolite_is_up_to_date def check_gitolite_is_up_to_date
print "Using recommended version ... " print "Using recommended version ... "
if gitolite_version.try(:start_with?, "v3.04") if gitolite_version.try(:start_with?, "v3.2")
puts "yes".green puts "yes".green
else else
puts "no".red puts "no".red
@ -582,7 +583,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -611,7 +612,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -635,7 +636,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Setup GitLab Hooks" see_installation_guide_section "Setup GitLab Hooks"
) )
check_failed fix_and_rerun
end end
end end
@ -666,7 +667,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Setup GitLab Hooks" see_installation_guide_section "Setup GitLab Hooks"
) )
check_failed fix_and_rerun
end end
end end
@ -688,7 +689,27 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end
end
def check_repo_base_is_not_symlink
print "Repo base directory is a symlink? ... "
repo_base_path = Gitlab.config.gitolite.repos_path
unless File.exists?(repo_base_path)
puts "can't check because of previous errors".magenta
return
end
unless File.symlink?(repo_base_path)
puts "no".green
else
puts "yes".red
try_fixing_it(
"Make sure it's set to the real directory in config/gitlab.yml"
)
fix_and_rerun
end end
end end
@ -712,7 +733,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -738,7 +759,7 @@ namespace :gitlab do
for_more_information( for_more_information(
see_installation_guide_section "Gitolite" see_installation_guide_section "Gitolite"
) )
check_failed fix_and_rerun
end end
end end
@ -772,7 +793,7 @@ namespace :gitlab do
for_more_information( for_more_information(
"doc/raketasks/maintenance.md" "doc/raketasks/maintenance.md"
) )
check_failed fix_and_rerun
end end
end end
end end
@ -808,7 +829,7 @@ namespace :gitlab do
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
) )
check_failed fix_and_rerun
next next
end end
@ -822,7 +843,7 @@ namespace :gitlab do
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
) )
check_failed fix_and_rerun
end end
end end
end end
@ -880,7 +901,7 @@ namespace :gitlab do
see_installation_guide_section("Install Init Script"), see_installation_guide_section("Install Init Script"),
"see log/resque.log for possible errors" "see log/resque.log for possible errors"
) )
check_failed fix_and_rerun
end end
end end
end end
@ -889,7 +910,7 @@ namespace :gitlab do
# Helper methods # Helper methods
########################## ##########################
def check_failed def fix_and_rerun
puts " Please #{"fix the error above"} and rerun the checks.".red puts " Please #{"fix the error above"} and rerun the checks.".red
end end
@ -908,29 +929,6 @@ namespace :gitlab do
puts "" puts ""
end end
# Runs the given command
#
# Returns nil if the command was not found
# Returns the output of the command otherwise
#
# see also #run_and_match
def run(command)
unless `#{command} 2>/dev/null`.blank?
`#{command}`
end
end
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched
# Retunrs the MatchData if the pattern matched
#
# see also #run
# see also String#match
def run_and_match(command, pattern)
run(command).try(:match, pattern)
end
def see_database_guide def see_database_guide
"doc/install/databases.md" "doc/install/databases.md"
end end
@ -952,18 +950,4 @@ namespace :gitlab do
puts " #{step}" puts " #{step}"
end end
end end
def warn_user_is_not_gitlab
unless @warned_user_not_gitlab
current_user = run("whoami").chomp
unless current_user == "gitlab"
puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}"
puts " You are running as user #{current_user.magenta}, we hope you know what you are doing."
puts " Some tests may pass\/fail for the wrong reason."
puts " For meaningful results you should run this as user #{"gitlab".magenta}."
puts ""
end
@warned_user_not_gitlab = true
end
end
end end

View file

@ -12,7 +12,10 @@ namespace :gitlab do
debian_version = File.read('/etc/debian_version') debian_version = File.read('/etc/debian_version')
"Debian #{debian_version}" "Debian #{debian_version}"
end end
os_name.squish! os_name ||= if File.readable?('/etc/SuSE-release')
File.read('/etc/SuSE-release')
end
os_name.try(:squish!)
# check if there is an RVM environment # check if there is an RVM environment
rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s) rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s)
@ -80,31 +83,5 @@ namespace :gitlab do
puts "Git:\t\t#{Gitlab.config.git.bin_path}" puts "Git:\t\t#{Gitlab.config.git.bin_path}"
end end
# Helper methods
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched
# Retunrs the MatchData if the pattern matched
#
# see also #run
# see also String#match
def run_and_match(command, regexp)
run(command).try(:match, regexp)
end
# Runs the given command
#
# Returns nil if the command was not found
# Returns the output of the command otherwise
#
# see also #run_and_match
def run(command)
unless `#{command} 2>/dev/null`.blank?
`#{command}`
end
end
end end
end end

View file

@ -0,0 +1,39 @@
namespace :gitlab do
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched
# Retunrs the MatchData if the pattern matched
#
# see also #run
# see also String#match
def run_and_match(command, regexp)
run(command).try(:match, regexp)
end
# Runs the given command
#
# Returns nil if the command was not found
# Returns the output of the command otherwise
#
# see also #run_and_match
def run(command)
unless `#{command} 2>/dev/null`.blank?
`#{command}`
end
end
def warn_user_is_not_gitlab
unless @warned_user_not_gitlab
current_user = run("whoami").chomp
unless current_user == "gitlab"
puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}"
puts " You are running as user #{current_user.magenta}, we hope you know what you are doing."
puts " Things may work\/fail for the wrong reasons."
puts " For correct results you should run this as user #{"gitlab".magenta}."
puts ""
end
@warned_user_not_gitlab = true
end
end
end