Class: Letsencrypt::Cli::App
- Inherits:
-
Thor
- Object
- Thor
- Letsencrypt::Cli::App
- Defined in:
- lib/letsencrypt/cli/app.rb
Instance Method Summary collapse
- #__print_version ⇒ Object
- #authorize(*domains) ⇒ Object
- #authorize_all ⇒ Object
- #cert(*domains) ⇒ Object
- #check(path) ⇒ Object
- #manage(*domains) ⇒ Object
- #register(email) ⇒ Object
- #revoke(path) ⇒ Object
Instance Method Details
#__print_version ⇒ Object
105 106 107 |
# File 'lib/letsencrypt/cli/app.rb', line 105 def __print_version puts Letsencrypt::Cli::VERSION end |
#authorize(*domains) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/letsencrypt/cli/app.rb', line 39 def (*domains) rc = 0 domains.each do |domain| if !wrapper.(domain) rc = 1 end end if rc != 0 exit rc end end |
#authorize_all ⇒ Object
31 32 33 34 35 |
# File 'lib/letsencrypt/cli/app.rb', line 31 def lines = Dir[ File.join(@options[:webserver_dir], "*")].map{|file| File.read(file).lines.grep(/^\s*server_name/) }.flatten domains = lines.flatten.map{|i| i.strip.split(/[; ]/).drop(1) }.flatten.reject{|i| i.length < 3 }.uniq (*domains) end |
#cert(*domains) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/letsencrypt/cli/app.rb', line 58 def cert(*domains) if domains.length == 0 wrapper.log "no domains given", :fatal exit 1 end wrapper.cert(domains) end |
#check(path) ⇒ Object
68 69 70 71 72 |
# File 'lib/letsencrypt/cli/app.rb', line 68 def check(path) if !wrapper.check_certificate(path) exit 1 end end |
#manage(*domains) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/letsencrypt/cli/app.rb', line 87 def manage(*domains) key_dir = File.join(@options[:key_directory], @options[:sub_directory] || domains.first) FileUtils.mkdir_p(key_dir) @options = @options.merge( :private_key_path => File.join(key_dir, 'key.pem'), :fullchain_path => File.join(key_dir, 'fullchain.pem'), :certificate_path => File.join(key_dir, 'cert.pem'), :chain_path => File.join(key_dir, 'chain.pem'), ) if wrapper.check_certificate(@options[:certificate_path]) exit 2 end (*domains) cert(*domains) end |
#register(email) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/letsencrypt/cli/app.rb', line 14 def register(email) if email.nil? || email == "" wrapper.log "no E-Mail specified!", :fatal exit 1 end if !email[/.*@.*/] wrapper.log "not an email", :fatal exit 1 end registration = wrapper.client.register(contact: "mailto:" + email) registration.agree_terms wrapper.log "Account created, Terms accepted" end |
#revoke(path) ⇒ Object
75 76 77 78 79 |
# File 'lib/letsencrypt/cli/app.rb', line 75 def revoke(path) if !wrapper.revoke_certificate(path) exit 1 end end |