Class: AcmeNsupdate::Cli
- Inherits:
-
Object
- Object
- AcmeNsupdate::Cli
- Defined in:
- lib/acme_nsupdate/cli.rb
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ Cli
Returns a new instance of Cli.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/acme_nsupdate/cli.rb', line 8 def initialize argv=ARGV @options = Slop.parse(argv) do |o| o.array "-d", "--domains", "The FQDNs to request a certificate for, multiple should be comma separated." o.string "-m", "--master", "The nameserver to use to provision the TXT and TLSA records to. Defaults to the primary nameserver specifed in the SOA record." o.string "-t", "--ttl", "The TTLs of the TXT and TLSA records created, separated by a comma. Defaults to 60,43200", default: "60,43200" o.bool "-k", "--keep", "Skip removing any kind of temporary data after successfully obtaining the certificate." o.string "-K", "--tsig", "TSIG key to use for DNS updates. Expected format is name:key." o.string "-e", "--endpoint", "ACME API endpoint directory. Defaults to: https://acme-v02.api.letsencrypt.org/directory", default: "https://acme-v02.api.letsencrypt.org/directory" o.string "-D", "--datadir", "Base directory for certificates and account keys. Defaults to: /etc/letsencrypt", default: "/etc/letsencrypt" o.string "-c", "--contact", "Contact mail address." o.integer "-l", "--keylength", "Length of the generated RSA keys. Defaults to 2048.", default: 2048 o.bool "-T", "--notlsa", "Do not publish TLSA records (publishing them drops all old ones). Defaults to no.", default: false o.array "-p", "--tlsaports", "Ports to publish TLSA records for. A plain port publishes for all FQDNs given, fqdn:port publishes for a single FQDN, [fqdn1 fqdn2]:port publishes for a subset. Multiple values should be comma separated. Defaults to 443.", default: ["443"] o.string "-C", "--challenge", "Challenge to use, either http-01 or dns-01. http-01 requires the webroot option. Defaults to http-01.", default: "http-01" o.string "-w", "--webroot", "Webroot to save http-01 challenges to." o.bool "-V", "--verbose", "Enable debug logging.", default: false o.bool "-q", "--quiet", "Only print error messages.", default: false o.bool "-f", "--force", "Force, even if cert is still valid.", default: false o.on "-v", "--version", "Display version." do puts "ACME nsupdate #{AcmeNsupdate::VERSION}" exit end o.on "-h", "--help", "Display this help." do puts o exit end end abort "Unexpected extra arguments #{@options.arguments}" unless @options.arguments.empty? @options = @options.to_h abort "You need to provide a domain!" unless domain_given? abort "A domain was given more than once!" unless domains_unique? abort "You need to provide a contact mail address!" unless contact_given? abort "Invalid TSIG key: name or key missing!" unless valid_tsig? abort "No webroot given or not writable!" unless valid_webroot? abort "Invalid TTL specification" unless valid_ttl? abort "Can't silence output and enable debug logging at the same time." unless valid_verbosity? @options[:txt_ttl], @options[:tlsa_ttl] = @options[:ttl].split(",") end |