Class: Acmesmith::PostIssuingHooks::Shell

Inherits:
Base
  • Object
show all
Defined in:
lib/acmesmith/post_issuing_hooks/shell.rb

Instance Attribute Summary

Attributes inherited from Base

#certificate

Instance Method Summary collapse

Methods inherited from Base

#common_name, #run

Constructor Details

#initialize(command:, ignore_failure: false) ⇒ Shell

Returns a new instance of Shell.



7
8
9
10
# File 'lib/acmesmith/post_issuing_hooks/shell.rb', line 7

def initialize(command:, ignore_failure: false)
  @command = command
  @ignore_failure = ignore_failure
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/acmesmith/post_issuing_hooks/shell.rb', line 12

def execute
  puts "=> Executing Post Issueing Hook for #{common_name} in #{self.class.name}"
  puts " $ #{@command}"

  status = system({"COMMON_NAME" => common_name}, @command)

  unless status
    if @ignore_failure
      $stderr.puts " ! execution failed"
    else
      raise "Execution failed"
    end
  end
end