Class: Letsencrypt::Cli::App

Inherits:
Thor
  • Object
show all
Defined in:
lib/letsencrypt/cli/app.rb

Instance Method Summary collapse

Instance Method Details

#__print_versionObject



68
69
70
# File 'lib/letsencrypt/cli/app.rb', line 68

def __print_version
  puts Letsencrypt::Cli::VERSION
end

#authorize(*domains) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/letsencrypt/cli/app.rb', line 38

def authorize(*domains)
  rc = 0
  domains.each do |domain|
    if !wrapper.authorize(domain)
      rc = 1
    end
  end
  if rc != 0
    exit rc
  end
end

#authorize_allObject



30
31
32
33
34
# File 'lib/letsencrypt/cli/app.rb', line 30

def authorize_all
  lines = Dir['/etc/nginx/sites-enabled/*'].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
  authorize(*domains)
end

#cert(*domains) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/letsencrypt/cli/app.rb', line 57

def cert(*domains)
  if domains.length == 0
    $stderr.puts "no domains given"
    exit 1
  end
  wrapper.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 == ""
    log "no E-Mail specified!", :fatal
    exit 1
  end
  if !email[/.*@.*/]
    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