Skip to content
Snippets Groups Projects

4 0 stable

Closed gitlab-qa-bot requested to merge 4-0-stable into master
1 file
+ 8
9
Compare changes
  • Side-by-side
  • Inline
+ 79
97
@@ -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
@@ -142,7 +142,7 @@ namespace :gitlab do
return
end
recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null`
recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/4-0-stable/init.d/gitlab 2>/dev/null`
script_content = File.read(script_path)
if recipe_content == script_content
@@ -155,7 +155,7 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Install Init Script"
)
check_failed
fix_and_rerun
end
end
@@ -169,9 +169,9 @@ namespace :gitlab do
else
puts "no".red
try_fixing_it(
"sudo -u gitlab -H bundle exec rake db:migrate"
"sudo -u gitlab -H bundle exec rake db:migrate RAILS_ENV=production"
)
check_failed
fix_and_rerun
end
end
@@ -194,14 +194,14 @@ namespace :gitlab do
else
puts "no".red
try_fixing_it(
"sudo -u gitlab -H bundle exec rake gitlab:satellites:create",
"sudo -u gitlab -H bundle exec rake gitlab:satellites:create RAILS_ENV=production",
"If necessary, remove the tmp/repo_satellites directory ...",
"... and rerun the above command"
)
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,16 +308,16 @@ 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 ... "
profile_file = File.join(gitolite_home, ".profile")
profile_file = File.join(gitolite_user_home, ".profile")
unless File.read(profile_file) =~ /^-e PATH/
puts "yes".green
@@ -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
@@ -474,7 +475,7 @@ namespace :gitlab do
def check_dot_gitolite_exists
print "Config directory exists? ... "
gitolite_config_path = File.join(gitolite_home, ".gitolite")
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
if File.directory?(gitolite_config_path)
puts "yes".green
@@ -488,20 +489,20 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
def check_dot_gitolite_permissions
print "Config directory access is drwxr-x---? ... "
gitolite_config_path = File.join(gitolite_home, ".gitolite")
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
unless File.exists?(gitolite_config_path)
puts "can't check because of previous errors".magenta
return
end
if `stat --printf %a #{gitolite_config_path}` == "750"
if File.stat(gitolite_config_path).mode.to_s(8).ends_with?("750")
puts "yes".green
else
puts "no".red
@@ -511,7 +512,7 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
@@ -519,31 +520,30 @@ namespace :gitlab do
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... "
gitolite_config_path = File.join(gitolite_home, ".gitolite")
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
unless File.exists?(gitolite_config_path)
puts "can't check because of previous errors".magenta
return
end
if `stat --printf %U #{gitolite_config_path}` == gitolite_ssh_user && # user
`stat --printf %G #{gitolite_config_path}` == gitolite_ssh_user #group
if File.stat(gitolite_config_path).uid == uid_for(gitolite_ssh_user) &&
File.stat(gitolite_config_path).gid == gid_for(gitolite_ssh_user)
puts "yes".green
else
puts "no".red
puts "#{gitolite_config_path} is not owned by #{gitolite_ssh_user}".red
try_fixing_it(
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{gitolite_config_path}"
)
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
@@ -558,7 +558,7 @@ namespace :gitlab do
end
def check_gitoliterc_git_config_keys
gitoliterc_path = File.join(gitolite_home, ".gitolite.rc")
gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc")
print "Allow all Git config keys in .gitolite.rc ... "
option_name = if has_gitolite3?
@@ -567,7 +567,7 @@ namespace :gitlab do
else
# assume older version
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L49
"$GL_GITCONFIG_KEYS"
"\\$GL_GITCONFIG_KEYS"
end
option_value = ".*"
if open(gitoliterc_path).grep(/#{option_name}\s*=[>]?\s*["']#{option_value}["']/).any?
@@ -582,12 +582,12 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
def check_gitoliterc_repo_umask
gitoliterc_path = File.join(gitolite_home, ".gitolite.rc")
gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc")
print "Repo umask is 0007 in .gitolite.rc? ... "
option_name = if has_gitolite3?
@@ -596,7 +596,7 @@ namespace :gitlab do
else
# assume older version
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L32
"$REPO_UMASK"
"\\$REPO_UMASK"
end
option_value = "0007"
if open(gitoliterc_path).grep(/#{option_name}\s*=[>]?\s*#{option_value}/).any?
@@ -611,7 +611,7 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
@@ -635,7 +635,7 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Setup GitLab Hooks"
)
check_failed
fix_and_rerun
end
end
@@ -666,7 +666,7 @@ namespace :gitlab do
for_more_information(
see_installation_guide_section "Setup GitLab Hooks"
)
check_failed
fix_and_rerun
end
end
@@ -688,7 +688,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
@@ -701,18 +721,17 @@ namespace :gitlab do
return
end
if `stat --printf %a #{repo_base_path}` == "6770"
if File.stat(repo_base_path).mode.to_s(8).ends_with?("6770")
puts "yes".green
else
puts "no".red
puts "#{repo_base_path} is not writable".red
try_fixing_it(
"sudo chmod -R ug+rwXs,o-rwx #{repo_base_path}"
)
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
@@ -726,19 +745,18 @@ namespace :gitlab do
return
end
if `stat --printf %U #{repo_base_path}` == gitolite_ssh_user && # user
`stat --printf %G #{repo_base_path}` == gitolite_ssh_user #group
if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) &&
File.stat(repo_base_path).gid == gid_for(gitolite_ssh_user)
puts "yes".green
else
puts "no".red
puts "#{repo_base_path} is not owned by #{gitolite_ssh_user}".red
try_fixing_it(
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{repo_base_path}"
)
for_more_information(
see_installation_guide_section "Gitolite"
)
check_failed
fix_and_rerun
end
end
@@ -767,12 +785,12 @@ namespace :gitlab do
else
puts "wrong or missing".red
try_fixing_it(
"sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos"
"sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production"
)
for_more_information(
"doc/raketasks/maintenance.md"
)
check_failed
fix_and_rerun
end
end
end
@@ -808,11 +826,12 @@ namespace :gitlab do
for_more_information(
"lib/support/rewrite-hooks.sh"
)
check_failed
fix_and_rerun
next
end
if run_and_match("stat --format %N #{project_hook_file}", /#{hook_file}.+->.+#{gitolite_hook_file}/)
if File.lstat(project_hook_file).symlink? &&
File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
puts "ok".green
else
puts "not a link to Gitolite's hook".red
@@ -822,7 +841,7 @@ namespace :gitlab do
for_more_information(
"lib/support/rewrite-hooks.sh"
)
check_failed
fix_and_rerun
end
end
end
@@ -831,12 +850,12 @@ namespace :gitlab do
# Helper methods
########################
def gitolite_home
def gitolite_user_home
File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
end
def gitolite_version
gitolite_version_file = "#{gitolite_home}/gitolite/src/VERSION"
gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION"
if File.readable?(gitolite_version_file)
File.read(gitolite_version_file)
end
@@ -880,7 +899,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 +908,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 +927,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 +948,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
Loading