Backport fixes to the check and info tasks
This commit is contained in:
parent
10b312abad
commit
0e2880b740
|
@ -89,6 +89,7 @@ backup:
|
|||
## Gitolite settings
|
||||
gitolite:
|
||||
admin_uri: git@localhost:gitolite-admin
|
||||
# repos_path must not be a symlink
|
||||
repos_path: /home/git/repositories/
|
||||
hooks_path: /home/git/.gitolite/hooks/
|
||||
admin_key: gitlab
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace :gitlab do
|
|||
see_database_guide,
|
||||
"http://guides.rubyonrails.org/getting_started.html#configuring-a-database"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace :gitlab do
|
|||
"https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL",
|
||||
see_database_guide
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "GitLab"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace :gitlab do
|
|||
end
|
||||
|
||||
# omniauth or ldap could have been deleted from the file
|
||||
unless Gitlab.config.pre_40_config
|
||||
unless Gitlab.config['git_host']
|
||||
puts "no".green
|
||||
else
|
||||
puts "yes".red
|
||||
|
@ -110,7 +110,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "GitLab"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Install Init Script"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Install Init Script"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -171,7 +171,7 @@ namespace :gitlab do
|
|||
try_fixing_it(
|
||||
"sudo -u gitlab -H bundle exec rake db:migrate"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
"doc/raketasks/maintenance.md "
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -222,7 +222,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "GitLab"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -242,7 +242,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "GitLab"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -256,7 +256,7 @@ namespace :gitlab do
|
|||
start_checking "Environment"
|
||||
|
||||
check_gitlab_in_git_group
|
||||
check_issue_1056_shell_profile_error
|
||||
check_issue_1059_shell_profile_error
|
||||
check_gitlab_git_config
|
||||
check_python2_exists
|
||||
check_python2_version
|
||||
|
@ -290,7 +290,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "GitLab"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -308,12 +308,12 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "System Users"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
# 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
|
||||
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
|
||||
|
||||
|
@ -332,7 +332,7 @@ namespace :gitlab do
|
|||
see_installation_guide_section("Gitolite"),
|
||||
"https://github.com/gitlabhq/gitlabhq/issues/1059"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -352,7 +352,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Packages / Dependencies"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -378,7 +378,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Packages / Dependencies"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -398,6 +398,7 @@ namespace :gitlab do
|
|||
check_dot_gitolite_user_and_group
|
||||
check_dot_gitolite_permissions
|
||||
check_repo_base_exists
|
||||
check_repo_base_is_not_symlink
|
||||
check_repo_base_user_and_group
|
||||
check_repo_base_permissions
|
||||
check_can_clone_gitolite_admin
|
||||
|
@ -434,7 +435,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
|
||||
# assumes #check_can_clone_gitolite_admin has been run before
|
||||
|
@ -466,7 +467,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
ensure
|
||||
FileUtils.rm_rf("/tmp/gitolite_gitlab_test")
|
||||
end
|
||||
|
@ -488,7 +489,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -511,7 +512,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -537,13 +538,13 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
def check_gitolite_is_up_to_date
|
||||
print "Using recommended version ... "
|
||||
if gitolite_version.try(:start_with?, "v3.04")
|
||||
if gitolite_version.try(:start_with?, "v3.2")
|
||||
puts "yes".green
|
||||
else
|
||||
puts "no".red
|
||||
|
@ -582,7 +583,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -611,7 +612,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -635,7 +636,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Setup GitLab Hooks"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -666,7 +667,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Setup GitLab Hooks"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -688,7 +689,27 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
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
|
||||
|
||||
|
@ -712,7 +733,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -738,7 +759,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -772,7 +793,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
"doc/raketasks/maintenance.md"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -808,7 +829,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
"lib/support/rewrite-hooks.sh"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -822,7 +843,7 @@ namespace :gitlab do
|
|||
for_more_information(
|
||||
"lib/support/rewrite-hooks.sh"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -880,7 +901,7 @@ namespace :gitlab do
|
|||
see_installation_guide_section("Install Init Script"),
|
||||
"see log/resque.log for possible errors"
|
||||
)
|
||||
check_failed
|
||||
fix_and_rerun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -889,7 +910,7 @@ namespace :gitlab do
|
|||
# Helper methods
|
||||
##########################
|
||||
|
||||
def check_failed
|
||||
def fix_and_rerun
|
||||
puts " Please #{"fix the error above"} and rerun the checks.".red
|
||||
end
|
||||
|
||||
|
@ -908,29 +929,6 @@ namespace :gitlab do
|
|||
puts ""
|
||||
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
|
||||
"doc/install/databases.md"
|
||||
end
|
||||
|
@ -952,18 +950,4 @@ namespace :gitlab do
|
|||
puts " #{step}"
|
||||
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
|
||||
|
|
|
@ -12,7 +12,10 @@ namespace :gitlab do
|
|||
debian_version = File.read('/etc/debian_version')
|
||||
"Debian #{debian_version}"
|
||||
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
|
||||
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}"
|
||||
|
||||
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
|
||||
|
|
39
lib/tasks/gitlab/task_helpers.rake
Normal file
39
lib/tasks/gitlab/task_helpers.rake
Normal 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
|
Loading…
Reference in a new issue