2012-04-04 00:02:54 +02:00
|
|
|
namespace :gitlab do
|
2012-12-10 14:50:55 +01:00
|
|
|
desc "GITLAB | Check the configuration of GitLab and its environment"
|
|
|
|
task check: %w{gitlab:env:check
|
|
|
|
gitlab:gitolite:check
|
2013-01-10 00:08:15 +01:00
|
|
|
gitlab:sidekiq:check
|
2012-12-13 12:11:41 +01:00
|
|
|
gitlab:app:check}
|
|
|
|
|
|
|
|
|
2012-12-10 14:50:55 +01:00
|
|
|
|
2012-04-04 00:02:54 +02:00
|
|
|
namespace :app do
|
2012-12-10 14:50:55 +01:00
|
|
|
desc "GITLAB | Check the configuration of the GitLab Rails app"
|
|
|
|
task check: :environment do
|
2012-12-13 12:11:41 +01:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
start_checking "GitLab"
|
|
|
|
|
|
|
|
check_database_config_exists
|
|
|
|
check_database_is_not_sqlite
|
|
|
|
check_migrations_are_up
|
|
|
|
check_gitlab_config_exists
|
|
|
|
check_gitlab_config_not_outdated
|
|
|
|
check_log_writable
|
|
|
|
check_tmp_writable
|
|
|
|
check_init_script_exists
|
|
|
|
check_init_script_up_to_date
|
|
|
|
check_satellites_exist
|
|
|
|
|
|
|
|
finished_checking "GitLab"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Checks
|
|
|
|
########################
|
|
|
|
|
|
|
|
def check_database_config_exists
|
|
|
|
print "Database config exists? ... "
|
|
|
|
|
|
|
|
database_config_file = Rails.root.join("config", "database.yml")
|
|
|
|
|
|
|
|
if File.exists?(database_config_file)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Copy config/database.yml.<your db> to config/database.yml",
|
|
|
|
"Check that the information in config/database.yml is correct"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_database_guide,
|
|
|
|
"http://guides.rubyonrails.org/getting_started.html#configuring-a-database"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_database_is_not_sqlite
|
2012-12-23 20:47:55 +01:00
|
|
|
print "Database is SQLite ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
database_config_file = Rails.root.join("config", "database.yml")
|
|
|
|
|
2012-12-24 15:52:49 +01:00
|
|
|
unless File.read(database_config_file) =~ /adapter:\s+sqlite/
|
2012-12-23 20:47:55 +01:00
|
|
|
puts "no".green
|
2012-12-13 12:11:41 +01:00
|
|
|
else
|
2012-12-23 20:47:55 +01:00
|
|
|
puts "yes".red
|
2012-12-13 12:11:41 +01:00
|
|
|
for_more_information(
|
|
|
|
"https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL",
|
|
|
|
see_database_guide
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitlab_config_exists
|
|
|
|
print "GitLab config exists? ... "
|
|
|
|
|
|
|
|
gitlab_config_file = Rails.root.join("config", "gitlab.yml")
|
|
|
|
|
|
|
|
if File.exists?(gitlab_config_file)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Copy config/gitlab.yml.example to config/gitlab.yml",
|
|
|
|
"Update config/gitlab.yml to match your setup"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "GitLab"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitlab_config_not_outdated
|
2012-12-20 16:51:14 +01:00
|
|
|
print "GitLab config outdated? ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
gitlab_config_file = Rails.root.join("config", "gitlab.yml")
|
|
|
|
unless File.exists?(gitlab_config_file)
|
|
|
|
puts "can't check because of previous errors".magenta
|
|
|
|
end
|
|
|
|
|
|
|
|
# omniauth or ldap could have been deleted from the file
|
2013-01-07 19:47:53 +01:00
|
|
|
unless Gitlab.config['git_host']
|
2012-12-20 16:51:14 +01:00
|
|
|
puts "no".green
|
2012-12-13 12:11:41 +01:00
|
|
|
else
|
2012-12-20 16:51:14 +01:00
|
|
|
puts "yes".red
|
2012-12-13 12:11:41 +01:00
|
|
|
try_fixing_it(
|
2012-12-20 16:51:14 +01:00
|
|
|
"Backup your config/gitlab.yml",
|
2012-12-13 12:11:41 +01:00
|
|
|
"Copy config/gitlab.yml.example to config/gitlab.yml",
|
|
|
|
"Update config/gitlab.yml to match your setup"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "GitLab"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
2012-04-04 00:02:54 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
def check_init_script_exists
|
|
|
|
print "Init script exists? ... "
|
|
|
|
|
|
|
|
script_path = "/etc/init.d/gitlab"
|
|
|
|
|
|
|
|
if File.exists?(script_path)
|
|
|
|
puts "yes".green
|
2012-09-26 13:18:10 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Install the init script"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Install Init Script"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_init_script_up_to_date
|
|
|
|
print "Init script up-to-date? ... "
|
|
|
|
|
|
|
|
script_path = "/etc/init.d/gitlab"
|
|
|
|
unless File.exists?(script_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null`
|
|
|
|
script_content = File.read(script_path)
|
|
|
|
|
|
|
|
if recipe_content == script_content
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Redownload the init script"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Install Init Script"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_migrations_are_up
|
|
|
|
print "All migrations up? ... "
|
|
|
|
|
|
|
|
migration_status = `bundle exec rake db:migrate:status`
|
|
|
|
|
|
|
|
unless migration_status =~ /down\s+\d{14}/
|
|
|
|
puts "yes".green
|
2012-04-04 00:02:54 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo -u gitlab -H bundle exec rake db:migrate"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_satellites_exist
|
|
|
|
print "Projects have satellites? ... "
|
|
|
|
|
|
|
|
unless Project.count > 0
|
|
|
|
puts "can't check, you have no projects".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
2012-12-13 12:11:41 +01:00
|
|
|
puts ""
|
|
|
|
|
|
|
|
Project.find_each(batch_size: 100) do |project|
|
2012-12-14 21:12:05 +01:00
|
|
|
print "#{project.name_with_namespace.yellow} ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
if project.satellite.exists?
|
|
|
|
puts "yes".green
|
2012-12-23 20:47:31 +01:00
|
|
|
elsif project.empty_repo?
|
|
|
|
puts "can't create, repository is empty".magenta
|
2012-12-13 12:11:41 +01:00
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-20 21:52:26 +01:00
|
|
|
"sudo -u gitlab -H bundle exec rake gitlab:satellites:create",
|
|
|
|
"If necessary, remove the tmp/repo_satellites directory ...",
|
|
|
|
"... and rerun the above command"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
"doc/raketasks/maintenance.md "
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_log_writable
|
|
|
|
print "Log directory writable? ... "
|
|
|
|
|
|
|
|
log_path = Rails.root.join("log")
|
|
|
|
|
|
|
|
if File.writable?(log_path)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo chown -R gitlab #{log_path}",
|
|
|
|
"sudo chmod -R rwX #{log_path}"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "GitLab"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_tmp_writable
|
|
|
|
print "Tmp directory writable? ... "
|
|
|
|
|
|
|
|
tmp_path = Rails.root.join("tmp")
|
|
|
|
|
|
|
|
if File.writable?(tmp_path)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo chown -R gitlab #{tmp_path}",
|
|
|
|
"sudo chmod -R rwX #{tmp_path}"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "GitLab"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
2012-12-10 14:50:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
|
2012-12-10 14:50:55 +01:00
|
|
|
namespace :env do
|
|
|
|
desc "GITLAB | Check the configuration of the environment"
|
|
|
|
task check: :environment do
|
2012-12-13 12:11:41 +01:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
start_checking "Environment"
|
|
|
|
|
|
|
|
check_gitlab_in_git_group
|
2013-01-04 16:14:55 +01:00
|
|
|
check_issue_1059_shell_profile_error
|
2012-12-13 12:11:41 +01:00
|
|
|
check_gitlab_git_config
|
|
|
|
check_python2_exists
|
|
|
|
check_python2_version
|
|
|
|
|
|
|
|
finished_checking "Environment"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Checks
|
|
|
|
########################
|
|
|
|
|
|
|
|
def check_gitlab_git_config
|
|
|
|
print "Git configured for gitlab user? ... "
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"user.name" => "GitLab",
|
2012-12-15 01:16:25 +01:00
|
|
|
"user.email" => Gitlab.config.gitlab.email_from
|
2012-12-13 12:11:41 +01:00
|
|
|
}
|
|
|
|
correct_options = options.map do |name, value|
|
|
|
|
run("git config --global --get #{name}").try(:squish) == value
|
|
|
|
end
|
|
|
|
|
|
|
|
if correct_options.all?
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo -u gitlab -H git config --global user.name \"#{options["user.name"]}\"",
|
|
|
|
"sudo -u gitlab -H git config --global user.email \"#{options["user.email"]}\""
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "GitLab"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitlab_in_git_group
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-14 20:20:26 +01:00
|
|
|
print "gitlab user is in #{gitolite_ssh_user} group? ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
if run_and_match("id -rnG", /\Wgit\W/)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo usermod -a -G #{gitolite_ssh_user} gitlab"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "System Users"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# see https://github.com/gitlabhq/gitlabhq/issues/1059
|
2013-01-04 16:14:55 +01:00
|
|
|
def check_issue_1059_shell_profile_error
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-14 20:20:26 +01:00
|
|
|
print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
2013-01-11 22:25:18 +01:00
|
|
|
profile_file = File.join(gitolite_user_home, ".profile")
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
unless File.read(profile_file) =~ /^-e PATH/
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Open #{profile_file}",
|
|
|
|
"Find the line starting with \"-e PATH\"",
|
|
|
|
"Remove \"-e \" so the line starts with PATH"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section("Gitolite"),
|
|
|
|
"https://github.com/gitlabhq/gitlabhq/issues/1059"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_python2_exists
|
|
|
|
print "Has python2? ... "
|
|
|
|
|
|
|
|
# Python prints its version to STDERR
|
|
|
|
# so we can't just use run("python2 --version")
|
|
|
|
if run_and_match("which python2", /python2$/)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Make sure you have Python 2.5+ installed",
|
|
|
|
"Link it to python2"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Packages / Dependencies"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_python2_version
|
|
|
|
print "python2 is supported version? ... "
|
|
|
|
|
|
|
|
# Python prints its version to STDERR
|
|
|
|
# so we can't just use run("python2 --version")
|
|
|
|
|
|
|
|
unless run_and_match("which python2", /python2$/)
|
|
|
|
puts "can't check because of previous errors".magenta
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if `python2 --version 2>&1` =~ /2\.[567]\.\d/
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Make sure you have Python 2.5+ installed",
|
|
|
|
"Link it to python2"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Packages / Dependencies"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
2012-12-10 14:50:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
|
2012-12-10 14:50:55 +01:00
|
|
|
namespace :gitolite do
|
|
|
|
desc "GITLAB | Check the configuration of Gitolite"
|
|
|
|
task check: :environment do
|
2012-12-13 12:11:41 +01:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
start_checking "Gitolite"
|
|
|
|
|
|
|
|
check_gitolite_is_up_to_date
|
|
|
|
check_gitoliterc_repo_umask
|
|
|
|
check_gitoliterc_git_config_keys
|
|
|
|
check_dot_gitolite_exists
|
|
|
|
check_dot_gitolite_user_and_group
|
|
|
|
check_dot_gitolite_permissions
|
|
|
|
check_repo_base_exists
|
2013-01-07 19:39:15 +01:00
|
|
|
check_repo_base_is_not_symlink
|
2012-12-13 12:11:41 +01:00
|
|
|
check_repo_base_user_and_group
|
|
|
|
check_repo_base_permissions
|
|
|
|
check_can_clone_gitolite_admin
|
|
|
|
check_can_commit_to_gitolite_admin
|
|
|
|
check_post_receive_hook_exists
|
|
|
|
check_post_receive_hook_is_up_to_date
|
|
|
|
check_repos_post_receive_hooks_is_link
|
|
|
|
check_repos_git_config
|
|
|
|
|
|
|
|
finished_checking "Gitolite"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Checks
|
|
|
|
########################
|
|
|
|
|
|
|
|
def check_can_clone_gitolite_admin
|
|
|
|
print "Can clone gitolite-admin? ... "
|
|
|
|
|
|
|
|
test_path = "/tmp/gitlab_gitolite_admin_test"
|
|
|
|
FileUtils.rm_rf(test_path)
|
2012-12-15 01:16:25 +01:00
|
|
|
`git clone -q #{Gitlab.config.gitolite.admin_uri} #{test_path}`
|
2012-12-13 12:11:41 +01:00
|
|
|
raise unless $?.success?
|
|
|
|
|
|
|
|
puts "yes".green
|
|
|
|
rescue
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Make sure the \"admin_uri\" is set correctly in config/gitlab.yml",
|
|
|
|
"Try cloning it yourself with:",
|
2012-12-15 01:16:25 +01:00
|
|
|
" git clone -q #{Gitlab.config.gitolite.admin_uri} /tmp/gitolite-admin",
|
2012-12-13 12:11:41 +01:00
|
|
|
"Make sure Gitolite is installed correctly."
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# assumes #check_can_clone_gitolite_admin has been run before
|
|
|
|
def check_can_commit_to_gitolite_admin
|
|
|
|
print "Can commit to gitolite-admin? ... "
|
|
|
|
|
|
|
|
test_path = "/tmp/gitlab_gitolite_admin_test"
|
|
|
|
unless File.exists?(test_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(test_path) do
|
|
|
|
`touch foo && git add foo && git commit -qm foo`
|
|
|
|
raise unless $?.success?
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "yes".green
|
|
|
|
rescue
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Try committing to it yourself with:",
|
2012-12-15 01:16:25 +01:00
|
|
|
" git clone -q #{Gitlab.config.gitolite.admin_uri} /tmp/gitolite-admin",
|
2012-12-13 12:11:41 +01:00
|
|
|
" touch foo",
|
|
|
|
" git add foo",
|
|
|
|
" git commit -m \"foo\"",
|
|
|
|
"Make sure Gitolite is installed correctly."
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
ensure
|
|
|
|
FileUtils.rm_rf("/tmp/gitolite_gitlab_test")
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_dot_gitolite_exists
|
|
|
|
print "Config directory exists? ... "
|
|
|
|
|
2013-01-11 22:25:18 +01:00
|
|
|
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
if File.directory?(gitolite_config_path)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
puts "#{gitolite_config_path} is missing".red
|
|
|
|
try_fixing_it(
|
|
|
|
"This should have been created when setting up Gitolite.",
|
|
|
|
"Make sure Gitolite is installed correctly."
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_dot_gitolite_permissions
|
|
|
|
print "Config directory access is drwxr-x---? ... "
|
2012-04-04 00:02:54 +02:00
|
|
|
|
2013-01-11 22:25:18 +01:00
|
|
|
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
|
2012-12-13 12:11:41 +01:00
|
|
|
unless File.exists?(gitolite_config_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-12 00:44:40 +01:00
|
|
|
if File.stat(gitolite_config_path).mode.to_s(8).ends_with?("750")
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
2012-09-26 13:18:10 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo chmod 750 #{gitolite_config_path}"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_dot_gitolite_user_and_group
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-14 20:20:26 +01:00
|
|
|
print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
2013-01-11 22:25:18 +01:00
|
|
|
gitolite_config_path = File.join(gitolite_user_home, ".gitolite")
|
2012-12-13 12:11:41 +01:00
|
|
|
unless File.exists?(gitolite_config_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-12 00:44:40 +01:00
|
|
|
if File.stat(gitolite_config_path).uid == uid_for(gitolite_ssh_user) &&
|
|
|
|
File.stat(gitolite_config_path).gid == gid_for(gitolite_ssh_user)
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{gitolite_config_path}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitolite_is_up_to_date
|
|
|
|
print "Using recommended version ... "
|
2013-01-07 21:18:41 +01:00
|
|
|
if gitolite_version.try(:start_with?, "v3.2")
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"We strongly recommend using the version pointed out in the installation guide."
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
|
|
|
# this is not a "hard" failure
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitoliterc_git_config_keys
|
2013-01-11 22:25:18 +01:00
|
|
|
gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc")
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
print "Allow all Git config keys in .gitolite.rc ... "
|
|
|
|
option_name = if has_gitolite3?
|
|
|
|
# see https://github.com/sitaramc/gitolite/blob/v3.04/src/lib/Gitolite/Rc.pm#L329
|
|
|
|
"GIT_CONFIG_KEYS"
|
|
|
|
else
|
|
|
|
# assume older version
|
|
|
|
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L49
|
|
|
|
"$GL_GITCONFIG_KEYS"
|
|
|
|
end
|
|
|
|
option_value = ".*"
|
|
|
|
if open(gitoliterc_path).grep(/#{option_name}\s*=[>]?\s*["']#{option_value}["']/).any?
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Open #{gitoliterc_path}",
|
|
|
|
"Find the \"#{option_name}\" option",
|
|
|
|
"Change its value to \".*\""
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_gitoliterc_repo_umask
|
2013-01-11 22:25:18 +01:00
|
|
|
gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc")
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
print "Repo umask is 0007 in .gitolite.rc? ... "
|
|
|
|
option_name = if has_gitolite3?
|
|
|
|
# see https://github.com/sitaramc/gitolite/blob/v3.04/src/lib/Gitolite/Rc.pm#L328
|
|
|
|
"UMASK"
|
|
|
|
else
|
|
|
|
# assume older version
|
|
|
|
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L32
|
|
|
|
"$REPO_UMASK"
|
|
|
|
end
|
|
|
|
option_value = "0007"
|
|
|
|
if open(gitoliterc_path).grep(/#{option_name}\s*=[>]?\s*#{option_value}/).any?
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"Open #{gitoliterc_path}",
|
|
|
|
"Find the \"#{option_name}\" option",
|
|
|
|
"Change its value to \"0007\""
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_post_receive_hook_exists
|
|
|
|
print "post-receive hook exists? ... "
|
|
|
|
|
|
|
|
hook_file = "post-receive"
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
|
2012-12-13 12:11:41 +01:00
|
|
|
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
|
|
|
|
|
|
|
|
if File.exists?(gitolite_hook_file)
|
|
|
|
puts "yes".green
|
2012-04-04 00:02:54 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Setup GitLab Hooks"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_post_receive_hook_is_up_to_date
|
|
|
|
print "post-receive hook up-to-date? ... "
|
|
|
|
|
|
|
|
hook_file = "post-receive"
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
|
2012-12-13 12:11:41 +01:00
|
|
|
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
unless File.exists?(gitolite_hook_file)
|
|
|
|
puts "can't check because of previous errors".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-24 16:41:46 +01:00
|
|
|
gitolite_hook_content = File.read(gitolite_hook_file)
|
2012-12-13 12:11:41 +01:00
|
|
|
gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
|
|
|
|
gitlab_hook_content = File.read(gitlab_hook_file)
|
|
|
|
|
|
|
|
if gitolite_hook_content == gitlab_hook_content
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo -u #{gitolite_ssh_user} cp #{gitlab_hook_file} #{gitolite_hook_file}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Setup GitLab Hooks"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_repo_base_exists
|
|
|
|
print "Repo base directory exists? ... "
|
|
|
|
|
2012-12-15 01:16:25 +01:00
|
|
|
repo_base_path = Gitlab.config.gitolite.repos_path
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
if File.exists?(repo_base_path)
|
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
puts "#{repo_base_path} is missing".red
|
|
|
|
try_fixing_it(
|
|
|
|
"This should have been created when setting up Gitolite.",
|
|
|
|
"Make sure it's set correctly in config/gitlab.yml",
|
|
|
|
"Make sure Gitolite is installed correctly."
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-07 19:39:15 +01:00
|
|
|
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
|
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
def check_repo_base_permissions
|
|
|
|
print "Repo base access is drwsrws---? ... "
|
|
|
|
|
2012-12-15 01:16:25 +01:00
|
|
|
repo_base_path = Gitlab.config.gitolite.repos_path
|
2012-12-13 12:11:41 +01:00
|
|
|
unless File.exists?(repo_base_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-12 00:44:40 +01:00
|
|
|
if File.stat(repo_base_path).mode.to_s(8).ends_with?("6770")
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo chmod -R ug+rwXs,o-rwx #{repo_base_path}"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_repo_base_user_and_group
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-14 20:20:26 +01:00
|
|
|
print "Repo base owned by #{gitolite_ssh_user}:#{gitolite_ssh_user}? ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
2012-12-15 01:16:25 +01:00
|
|
|
repo_base_path = Gitlab.config.gitolite.repos_path
|
2012-12-13 12:11:41 +01:00
|
|
|
unless File.exists?(repo_base_path)
|
|
|
|
puts "can't check because of previous errors".magenta
|
2012-11-08 00:47:11 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-12 00:44:40 +01:00
|
|
|
if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) &&
|
|
|
|
File.stat(repo_base_path).gid == gid_for(gitolite_ssh_user)
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
2012-04-04 00:02:54 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{repo_base_path}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section "Gitolite"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_repos_git_config
|
|
|
|
print "Git config in repos: ... "
|
|
|
|
|
|
|
|
unless Project.count > 0
|
|
|
|
puts "can't check, you have no projects".magenta
|
2012-04-04 00:02:54 +02:00
|
|
|
return
|
|
|
|
end
|
2012-12-13 12:11:41 +01:00
|
|
|
puts ""
|
2012-04-04 00:02:54 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
options = {
|
|
|
|
"core.sharedRepository" => "0660",
|
|
|
|
}
|
|
|
|
|
|
|
|
Project.find_each(batch_size: 100) do |project|
|
2012-12-14 21:12:05 +01:00
|
|
|
print "#{project.name_with_namespace.yellow} ... "
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
correct_options = options.map do |name, value|
|
2013-01-07 19:04:20 +01:00
|
|
|
run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if correct_options.all?
|
|
|
|
puts "ok".green
|
2012-08-21 21:44:49 +02:00
|
|
|
else
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "wrong or missing".red
|
|
|
|
try_fixing_it(
|
|
|
|
"sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos"
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
"doc/raketasks/maintenance.md"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-08-21 21:44:49 +02:00
|
|
|
end
|
|
|
|
end
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_repos_post_receive_hooks_is_link
|
|
|
|
print "post-receive hooks in repos are links: ... "
|
|
|
|
|
|
|
|
hook_file = "post-receive"
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_hooks_path = File.join(Gitlab.config.gitolite.hooks_path, "common")
|
2012-12-13 12:11:41 +01:00
|
|
|
gitolite_hook_file = File.join(gitolite_hooks_path, hook_file)
|
2012-12-15 01:16:25 +01:00
|
|
|
gitolite_ssh_user = Gitlab.config.gitolite.ssh_user
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
unless File.exists?(gitolite_hook_file)
|
|
|
|
puts "can't check because of previous errors".magenta
|
|
|
|
return
|
|
|
|
end
|
2012-08-21 21:44:49 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
unless Project.count > 0
|
|
|
|
puts "can't check, you have no projects".magenta
|
|
|
|
return
|
|
|
|
end
|
|
|
|
puts ""
|
2012-07-26 15:14:34 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
Project.find_each(batch_size: 100) do |project|
|
2012-12-14 21:12:05 +01:00
|
|
|
print "#{project.name_with_namespace.yellow} ... "
|
2013-01-07 19:04:20 +01:00
|
|
|
project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file)
|
2012-07-26 15:14:34 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
unless File.exists?(project_hook_file)
|
|
|
|
puts "missing".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
"lib/support/rewrite-hooks.sh"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
next
|
|
|
|
end
|
2012-11-21 08:04:32 +01:00
|
|
|
|
2013-01-12 00:44:40 +01:00
|
|
|
if File.lstat(project_hook_file).symlink? &&
|
|
|
|
File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "ok".green
|
|
|
|
else
|
|
|
|
puts "not a link to Gitolite's hook".red
|
|
|
|
try_fixing_it(
|
2012-12-14 20:20:26 +01:00
|
|
|
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
"lib/support/rewrite-hooks.sh"
|
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-07-26 15:14:34 +02:00
|
|
|
end
|
|
|
|
end
|
2012-12-10 14:50:55 +01:00
|
|
|
end
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Helper methods
|
|
|
|
########################
|
|
|
|
|
2013-01-11 22:25:18 +01:00
|
|
|
def gitolite_user_home
|
2012-12-15 01:16:25 +01:00
|
|
|
File.expand_path("~#{Gitlab.config.gitolite.ssh_user}")
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def gitolite_version
|
2013-01-11 22:25:18 +01:00
|
|
|
gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION"
|
2012-12-13 12:11:41 +01:00
|
|
|
if File.readable?(gitolite_version_file)
|
|
|
|
File.read(gitolite_version_file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_gitolite3?
|
|
|
|
gitolite_version.try(:start_with?, "v3.")
|
|
|
|
end
|
2012-12-10 14:50:55 +01:00
|
|
|
end
|
2012-07-26 15:14:34 +02:00
|
|
|
|
2012-12-13 12:11:41 +01:00
|
|
|
|
|
|
|
|
2013-01-10 00:08:15 +01:00
|
|
|
namespace :sidekiq do
|
2013-01-09 07:14:05 +01:00
|
|
|
desc "GITLAB | Check the configuration of Sidekiq"
|
2012-12-10 14:50:55 +01:00
|
|
|
task check: :environment do
|
2012-12-13 12:11:41 +01:00
|
|
|
warn_user_is_not_gitlab
|
2013-01-10 00:08:15 +01:00
|
|
|
start_checking "Sidekiq"
|
2012-12-13 12:11:41 +01:00
|
|
|
|
2013-01-10 00:08:15 +01:00
|
|
|
check_sidekiq_running
|
2012-12-13 12:11:41 +01:00
|
|
|
|
2013-01-10 00:08:15 +01:00
|
|
|
finished_checking "Sidekiq"
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Checks
|
|
|
|
########################
|
|
|
|
|
2013-01-10 00:08:15 +01:00
|
|
|
def check_sidekiq_running
|
2012-12-13 12:11:41 +01:00
|
|
|
print "Running? ... "
|
|
|
|
|
2013-01-09 19:31:05 +01:00
|
|
|
if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d\.\d\.\d.+$/)
|
2012-12-13 12:11:41 +01:00
|
|
|
puts "yes".green
|
|
|
|
else
|
|
|
|
puts "no".red
|
|
|
|
try_fixing_it(
|
2013-01-10 00:08:15 +01:00
|
|
|
"sudo -u gitlab -H bundle exec rake sidekiq:start"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section("Install Init Script"),
|
2013-01-09 07:14:05 +01:00
|
|
|
"see log/sidekiq.log for possible errors"
|
2012-12-13 12:11:41 +01:00
|
|
|
)
|
2012-12-23 01:33:58 +01:00
|
|
|
fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Helper methods
|
|
|
|
##########################
|
|
|
|
|
2012-12-23 01:33:58 +01:00
|
|
|
def fix_and_rerun
|
2012-12-13 12:11:41 +01:00
|
|
|
puts " Please #{"fix the error above"} and rerun the checks.".red
|
|
|
|
end
|
|
|
|
|
|
|
|
def for_more_information(*sources)
|
|
|
|
sources = sources.shift if sources.first.is_a?(Array)
|
|
|
|
|
|
|
|
puts " For more information see:".blue
|
|
|
|
sources.each do |source|
|
|
|
|
puts " #{source}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def finished_checking(component)
|
|
|
|
puts ""
|
|
|
|
puts "Checking #{component.yellow} ... #{"Finished".green}"
|
|
|
|
puts ""
|
|
|
|
end
|
|
|
|
|
|
|
|
def see_database_guide
|
|
|
|
"doc/install/databases.md"
|
|
|
|
end
|
|
|
|
|
|
|
|
def see_installation_guide_section(section)
|
|
|
|
"doc/install/installation.md in section \"#{section}\""
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_checking(component)
|
|
|
|
puts "Checking #{component.yellow} ..."
|
|
|
|
puts ""
|
|
|
|
end
|
|
|
|
|
|
|
|
def try_fixing_it(*steps)
|
|
|
|
steps = steps.shift if steps.first.is_a?(Array)
|
|
|
|
|
|
|
|
puts " Try fixing it:".blue
|
|
|
|
steps.each do |step|
|
|
|
|
puts " #{step}"
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 00:02:54 +02:00
|
|
|
end
|