Class: CertWatch::CertbotClient

Inherits:
Client
  • Object
show all
Defined in:
lib/cert_watch/certbot_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CertbotClient

Returns a new instance of CertbotClient.


3
4
5
6
# File 'lib/cert_watch/certbot_client.rb', line 3

def initialize(options)
  @executable = options.fetch(:executable)
  @port = options.fetch(:port)
end

Instance Method Details

#renew(domain) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/cert_watch/certbot_client.rb', line 8

def renew(domain)
  if Rails.env.development?
    Rails.logger.info("[CertWatch] Skipping certificate renewal for #{domain} in development.")
    return
  end

  system(renew_command(domain))
end

#renew_command(domain) ⇒ Object


17
18
19
20
# File 'lib/cert_watch/certbot_client.rb', line 17

def renew_command(domain)
  Sanitize.check_domain!(domain)
  "sudo #{@executable} certonly #{flags} -d #{domain}"
end