Sha256: d89248edb8a74ec7b35441c29bc22c025f0d07221718136efea69285ef9a5a50

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

module Caco::Debian
  class ServiceInstall < Trailblazer::Operation
    step ->(ctx, name:, **) {
        ctx[:service_path] = "/etc/systemd/system/#{name}.service"
      },
      id: :generate_service_path

    step :generate_template_content

    step Subprocess(Caco::FileWriter),
      input: ->(_ctx, service_path:, template_content:, **) {{
        path: service_path,
        content: template_content
      }}

    step Subprocess(Caco::Executer),
      input: ->(_ctx, **) {{
        command: "systemctl daemon-reload",
      }},
      id: "systemctl_reload"

    def generate_template_content(ctx, description: nil, environment_file: nil, environment_vars: nil, command:, **)
      ctx[:template_content] = Caco::Debian::Cell::Service.(
        command: command,
        description: description,
        environment_file: environment_file,
        environment_vars: environment_vars,
      ).to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caco-0.1.0 lib/caco/debian/service_install.rb