class CertWatch::CertbotClient

Public Class Methods

new(options) click to toggle source
# File lib/cert_watch/certbot_client.rb, line 3
def initialize(options)
  @executable = options.fetch(:executable)
  @port = options.fetch(:port)
  @shell = options.fetch(:shell, Shell)
end

Public Instance Methods

renew(domain) click to toggle source
# File lib/cert_watch/certbot_client.rb, line 9
def renew(domain)
  if Rails.env.development?
    Rails.logger.info("[CertWatch] Skipping certificate renewal for #{domain} in development.")
    return
  end

  @shell.sudo(renew_command(domain))
rescue Shell::CommandFailed => e
  fail(RenewError, e.message)
end

Private Instance Methods

flags() click to toggle source
# File lib/cert_watch/certbot_client.rb, line 27
def flags
  '--agree-tos --renew-by-default ' \
  "--standalone --standalone-supported-challenges http-01 --http-01-port #{@port}"
end
renew_command(domain) click to toggle source
# File lib/cert_watch/certbot_client.rb, line 22
def renew_command(domain)
  Sanitize.check_domain!(domain)
  "#{@executable} certonly #{flags} -d #{domain}"
end