Class: DInstaller::CockpitManager

Inherits:
Object
  • Object
show all
Includes:
Yast::I18n, Yast::Logger, Yast::Transfer::FileFromUrl
Defined in:
lib/dinstaller/cockpit_manager.rb

Overview

Handles the Cockpit service

This API offers an API to adjust Cockpit configuration and restart/reload the process. At this point, just a few options are allowed (@see #setup).

Constant Summary collapse

WS_CERTS_DIR =

Directory to store Cockpit certificates

"/etc/cockpit/ws-certs.d"
COCKPIT_SERVICE =
"cockpit"
COCKPIT_CONF_PATH =
"/etc/cockpit/cockpit.conf"

Instance Method Summary collapse

Constructor Details

#initialize(logger, prefix: "/") ⇒ CockpitManager

Returns a new instance of CockpitManager.



72
73
74
75
# File 'lib/dinstaller/cockpit_manager.rb', line 72

def initialize(logger, prefix: "/")
  @prefix = prefix
  @logger = logger
end

Instance Method Details

#setup(options) ⇒ Object

Adjust Cockpit configuration and restart the process if needed

If all arguments are nil, the configuration is not modified and the process is not restarted.

Parameters:

  • config (Hash)

    @option ssl [Boolean,nil] SSL is enabled @option ssl_cert [String,nil] SSL/TLS certificate URL @option ssl_key [String,nil] SSL/TLS key URL



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/dinstaller/cockpit_manager.rb', line 85

def setup(options)
  return if options.values.all?(&:nil?)

  enable_ssl(options["ssl"]) unless options["ssl"].nil?
  if options["ssl_cert"]
    copy_ssl_cert(options["ssl_cert"])
    copy_ssl_key(options["ssl_key"]) unless options["ssl_key"].nil?
    clear_self_signed_cert
  end

  restart_cockpit
end