run_auto_wizard.rb 745 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::System::RunAutoWizard < Service::Base
  3. def execute(token:)
  4. raise AutoWizardNotEnabledError if !AutoWizard.enabled?
  5. auto_wizard_data = AutoWizard.data
  6. if auto_wizard_data.blank?
  7. raise AutoWizardExecutionError __('Invalid auto wizard file.')
  8. end
  9. if auto_wizard_data['Token'] && auto_wizard_data['Token'] != token
  10. raise AutoWizardExecutionError
  11. end
  12. AutoWizard.setup.tap do |admin_user|
  13. raise AutoWizardExecutionError __('Error during execution of auto wizard.') if !admin_user
  14. end
  15. end
  16. class AutoWizardNotEnabledError < StandardError; end
  17. class AutoWizardExecutionError < StandardError; end
  18. end