Sha256: e01daba2d05292561914ebc3ae0c6ac544084b4ef165e532d448c1db059eb7b4

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

module CertWatch
  class CertbotClient < Client
    def initialize(options)
      @executable = options.fetch(:executable)
      @port = options.fetch(:port)
      @shell = options.fetch(:shell, Shell)
    end

    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

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

    def flags
      '--agree-tos --renew-by-default ' \
      "--standalone --standalone-supported-challenges http-01 --http-01-port #{@port}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cert_watch-1.1.0 lib/cert_watch/certbot_client.rb
cert_watch-1.0.0 lib/cert_watch/certbot_client.rb