Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system_check/app')
-rw-r--r--lib/system_check/app/init_script_exists_check.rb29
-rw-r--r--lib/system_check/app/init_script_up_to_date_check.rb47
-rw-r--r--lib/system_check/app/systemd_unit_files_or_init_script_exist_check.rb39
-rw-r--r--lib/system_check/app/systemd_unit_files_or_init_script_up_to_date_check.rb80
4 files changed, 119 insertions, 76 deletions
diff --git a/lib/system_check/app/init_script_exists_check.rb b/lib/system_check/app/init_script_exists_check.rb
deleted file mode 100644
index 7be92acdc37..00000000000
--- a/lib/system_check/app/init_script_exists_check.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-module SystemCheck
- module App
- class InitScriptExistsCheck < SystemCheck::BaseCheck
- set_name 'Init script exists?'
- set_skip_reason 'skipped (omnibus-gitlab has no init script)'
-
- def skip?
- omnibus_gitlab?
- end
-
- def check?
- script_path = '/etc/init.d/gitlab'
- File.exist?(script_path)
- end
-
- def show_error
- try_fixing_it(
- 'Install the init script'
- )
- for_more_information(
- see_installation_guide_section('Install Init Script')
- )
- fix_and_rerun
- end
- end
- end
-end
diff --git a/lib/system_check/app/init_script_up_to_date_check.rb b/lib/system_check/app/init_script_up_to_date_check.rb
deleted file mode 100644
index cf841d5e659..00000000000
--- a/lib/system_check/app/init_script_up_to_date_check.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-module SystemCheck
- module App
- class InitScriptUpToDateCheck < SystemCheck::BaseCheck
- SCRIPT_PATH = '/etc/init.d/gitlab'
-
- set_name 'Init script up-to-date?'
- set_skip_reason 'skipped (omnibus-gitlab has no init script)'
-
- def skip?
- return true if omnibus_gitlab?
-
- unless init_file_exists?
- self.skip_reason = "can't check because of previous errors"
-
- true
- end
- end
-
- def check?
- recipe_path = Rails.root.join('lib/support/init.d/', 'gitlab')
-
- recipe_content = File.read(recipe_path)
- script_content = File.read(SCRIPT_PATH)
-
- recipe_content == script_content
- end
-
- def show_error
- try_fixing_it(
- 'Re-download the init script'
- )
- for_more_information(
- see_installation_guide_section('Install Init Script')
- )
- fix_and_rerun
- end
-
- private
-
- def init_file_exists?
- File.exist?(SCRIPT_PATH)
- end
- end
- end
-end
diff --git a/lib/system_check/app/systemd_unit_files_or_init_script_exist_check.rb b/lib/system_check/app/systemd_unit_files_or_init_script_exist_check.rb
new file mode 100644
index 00000000000..b2f059d212b
--- /dev/null
+++ b/lib/system_check/app/systemd_unit_files_or_init_script_exist_check.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+module SystemCheck
+ module App
+ class SystemdUnitFilesOrInitScriptExistCheck < SystemCheck::BaseCheck
+ set_name 'Systemd unit files or init script exist?'
+ set_skip_reason 'skipped (omnibus-gitlab has neither init script nor systemd units)'
+
+ def skip?
+ omnibus_gitlab?
+ end
+
+ def check?
+ unit_paths = [
+ '/usr/local/lib/systemd/system/gitlab-gitaly.service',
+ '/usr/local/lib/systemd/system/gitlab-mailroom.service',
+ '/usr/local/lib/systemd/system/gitlab-puma.service',
+ '/usr/local/lib/systemd/system/gitlab-sidekiq.service',
+ '/usr/local/lib/systemd/system/gitlab.slice',
+ '/usr/local/lib/systemd/system/gitlab.target',
+ '/usr/local/lib/systemd/system/gitlab-workhorse.service'
+ ]
+ script_path = '/etc/init.d/gitlab'
+
+ unit_paths.all? { |s| File.exist?(s) } || File.exist?(script_path)
+ end
+
+ def show_error
+ try_fixing_it(
+ 'Install the Service'
+ )
+ for_more_information(
+ see_installation_guide_section('Install the Service')
+ )
+ fix_and_rerun
+ end
+ end
+ end
+end
diff --git a/lib/system_check/app/systemd_unit_files_or_init_script_up_to_date_check.rb b/lib/system_check/app/systemd_unit_files_or_init_script_up_to_date_check.rb
new file mode 100644
index 00000000000..10bc772a83c
--- /dev/null
+++ b/lib/system_check/app/systemd_unit_files_or_init_script_up_to_date_check.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+module SystemCheck
+ module App
+ class SystemdUnitFilesOrInitScriptUpToDateCheck < SystemCheck::BaseCheck
+ SCRIPT_PATH = '/etc/init.d/gitlab'
+ UNIT_PATHS = [
+ '/usr/local/lib/systemd/system/gitlab-gitaly.service',
+ '/usr/local/lib/systemd/system/gitlab-mailroom.service',
+ '/usr/local/lib/systemd/system/gitlab-puma.service',
+ '/usr/local/lib/systemd/system/gitlab-sidekiq.service',
+ '/usr/local/lib/systemd/system/gitlab.slice',
+ '/usr/local/lib/systemd/system/gitlab.target',
+ '/usr/local/lib/systemd/system/gitlab-workhorse.service'
+ ].freeze
+
+ set_name 'Systemd unit files or init script up-to-date?'
+ set_skip_reason 'skipped (omnibus-gitlab has neither init script nor systemd units)'
+
+ def skip?
+ return true if omnibus_gitlab?
+
+ unless unit_files_exist? || init_file_exists?
+ self.skip_reason = "can't check because of previous errors"
+
+ true
+ end
+ end
+
+ def check?
+ if unit_files_exist?
+ return unit_files_up_to_date?
+ end
+
+ init_file_up_to_date?
+ end
+
+ def show_error
+ try_fixing_it(
+ 'Install the Service'
+ )
+ for_more_information(
+ see_installation_guide_section('Install the Service')
+ )
+ fix_and_rerun
+ end
+
+ private
+
+ def init_file_exists?
+ File.exist?(SCRIPT_PATH)
+ end
+
+ def unit_files_exist?
+ UNIT_PATHS.all? { |s| File.exist?(s) }
+ end
+
+ def init_file_up_to_date?
+ recipe_path = Rails.root.join('lib/support/init.d/', 'gitlab')
+
+ recipe_content = File.read(recipe_path)
+ script_content = File.read(SCRIPT_PATH)
+
+ recipe_content == script_content
+ end
+
+ def unit_files_up_to_date?
+ UNIT_PATHS.all? do |unit|
+ unit_name = File.basename(unit)
+ recipe_path = Rails.root.join('lib/support/systemd/', unit_name)
+
+ recipe_content = File.read(recipe_path)
+ unit_content = File.read(unit)
+
+ recipe_content == unit_content
+ end
+ end
+ end
+ end
+end