Sha256: 46eeddfe20d4df3fe4a6c5dd7137c47691de61ca22101320456d928fc56ea21f

Contents?: true

Size: 1.75 KB

Versions: 5

Compression:

Stored size: 1.75 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH << 'lib'
require 'clusterlb'
require 'colorize'
require 'getoptlong'

include Clusterlb

def display_help
	puts
  puts "Tool for getting SSL Certificates from AWS S3 or Let's Encrypt"
	puts "VERSION:        #{Clusterlb::VERSION}".colorize(:light_blue)
	puts "CONFIG:         #{Clusterlb.config_file}".colorize(:light_blue)
	puts "CLUSTERLB_HOME: #{ENV['CLUSTERLB_HOME']}".colorize(:light_blue)
	puts
	puts "Options:"
	puts "-h or --help ".ljust(30) 		  							+ "-> Display this help message"
	puts "-s or --s3".ljust(30)         							+ "-> Retrive an already stored certificate from AWS S3"
	puts "-l or --letsencrypt".ljust(30)       				+ "-> use Let's Encrypt to retrive an certificate"
	puts "-r or --renew-all-letsencrypt".ljust(30)    + "-> Attempt to renew all the Let's Encrypt Certificates"
	puts "-f or --fqdn".ljust(30)      								+ "-> FQDN of site to retreve certificate for"
	puts
	exit 1
end


def parse_cli
	@mode=nil
	@fqdn=nil
  opts = GetoptLong.new(
    ["-h", "--help", GetoptLong::NO_ARGUMENT],
    ["-s", "--s3", GetoptLong::NO_ARGUMENT],
		["-l", "--letsencrypt", GetoptLong::NO_ARGUMENT],
		["-r", "--renew-all-letsencrypt", GetoptLong::NO_ARGUMENT],
    ["-f", "--fqdn", GetoptLong::REQUIRED_ARGUMENT]
  )

  opts.each do |opt, arg|
    case opt
    when  "-h" || "--help"
      display_help; exit
		when "-s" || "--s3"
			@mode="s3"
    when "-l" || "--letsencrypt"
      @mode="le"
    when "-r" || "--renew-all-letsencrypt"
			@mode="le_all"
		when "-f" || "--fqdn"
			@fqdn = arg.strip().downcase();
    end
  end

end

parse_cli

if @mode == "s3"
	Clusterlb.get_s3_cert(@fqdn)
	exit
elsif @mode == "le_all"
	Clusterlb.letsEncrypt("all")
	exit
elsif @mode == "le"
	Clusterlb.letsEncrypt(@fqdn)
	exit
else
	display_help
	exit
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
clusterlb-0.1.16 exe/clusterlb-getcert
clusterlb-0.1.15 exe/clusterlb-getcert
clusterlb-0.1.14 exe/clusterlb-getcert
clusterlb-0.1.13 exe/clusterlb-getcert
clusterlb-0.1.12 exe/clusterlb-getcert