certflare 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/bin/certflare +6 -0
- data/bin/certflare_hook +6 -0
- data/certflare.gemspec +33 -0
- data/lib/certflare/cleanup.rb +58 -0
- data/lib/certflare/cli.rb +29 -0
- data/lib/certflare/commands/cert.rb +12 -0
- data/lib/certflare/common/authenticator.rb +69 -0
- data/lib/certflare/common/cleanup.rb +58 -0
- data/lib/certflare/initialization.rb +15 -0
- data/lib/certflare/logger.rb +13 -0
- data/lib/certflare/runner.rb +62 -0
- data/lib/certflare/version.rb +4 -0
- data/lib/certflare.rb +13 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e95734872d93df4da8d66b95f34306f63fcba3cd204a2cda84955b66aa71e6d
|
4
|
+
data.tar.gz: 1091044e556f275338b9732049809699f29efbd58e5f7396730f233cff5476bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 886186a59a5593422f10fd5c7fe7cc551c1b1fc1ba9027a60f878a5515b3e0b35fefe906abfc427f0640ba9e37614bf30ac62705b3aae4ab12a49de7a66a6497
|
7
|
+
data.tar.gz: '0708fdb6d5962aae8e97bb7bc0e7ead3d27ba10e25c2cc111827124a4b15974d0067c389dc7d0866b5a32dea4a57e07ef1fc920058de84892c4e0732c1e35120'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at me@iotaspencer.me. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ken Spencer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Certflare
|
2
|
+
|
3
|
+
Certflare is an easier and quicker way to your certs from certbot/letsencrypt/ietf.
|
4
|
+
Why make your own script when something does it better and easier, especially if you don't know ruby.
|
5
|
+
|
6
|
+
Just install this, run xxxxx and you'll be on your way,
|
7
|
+
and certbot and certflare will work together to keep
|
8
|
+
your certificates valid.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'certflare'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
gem install certflare
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### As a Hook
|
29
|
+
|
30
|
+
#### Authenticating:
|
31
|
+
|
32
|
+
certflare_hook auth [options]
|
33
|
+
|
34
|
+
certbot --auth-hook="certflare_hook auth [options]"
|
35
|
+
|
36
|
+
#### Cleaning Up
|
37
|
+
|
38
|
+
certflare_hook clean [options]
|
39
|
+
|
40
|
+
### As a client itself
|
41
|
+
|
42
|
+
certflare
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub
|
47
|
+
at [IotaSpencer/certflare](https://github.com/IotaSpencer/certflare).
|
48
|
+
|
49
|
+
This project is intended to be a safe, welcoming space for collaboration.
|
50
|
+
Contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
55
|
+
|
56
|
+
## Code of Conduct
|
57
|
+
|
58
|
+
Everyone interacting in the Certflare project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/IotaSpencer/certflare/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/certflare
ADDED
data/bin/certflare_hook
ADDED
data/certflare.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "certflare/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "certflare"
|
8
|
+
spec.version = Certflare::VERSION
|
9
|
+
spec.authors = ["Ken Spencer"]
|
10
|
+
spec.email = ["me@iotaspencer.me"]
|
11
|
+
|
12
|
+
spec.summary = %q{This summary is a summary of a summary}
|
13
|
+
spec.homepage = "https://iotaspencer.me/projects/certflare/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.add_dependency 'acme-client', '~> 2.0.2'
|
22
|
+
spec.add_dependency 'cloudflare_client_rb', '~> 4.2.6'
|
23
|
+
spec.add_dependency 'configparser', '~> 0.1.7'
|
24
|
+
spec.add_dependency 'highline', '~> 2.0.1'
|
25
|
+
spec.add_dependency 'public_suffix', '~> 3.0.3'
|
26
|
+
spec.add_dependency 'thor', '~> 0.20.3'
|
27
|
+
spec.add_dependency 'yell', '~> 2.1.0'
|
28
|
+
spec.add_dependency 'yell-adapters-syslog', '~> 2.0.2'
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency 'memfs', '~> 1.0.0'
|
33
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019 Ken Spencer / IotaSpencer
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# File: ${FILENAME}
|
6
|
+
# Created: 3/14/19
|
7
|
+
#
|
8
|
+
# License is in project root, MIT License is in use.
|
9
|
+
require 'cloudflare_client'
|
10
|
+
require 'configparser'
|
11
|
+
require 'pathname'
|
12
|
+
require 'public_suffix'
|
13
|
+
|
14
|
+
module Certflare
|
15
|
+
class CleanUp
|
16
|
+
@@configs_dir = Pathname.new('/sites/configs/dns-cloudflare-credentials/')
|
17
|
+
@@cfg = ConfigParser.new(@@configs_dir.join('cloudflare.ini'))
|
18
|
+
@@api_key = @@cfg['dns_cloudflare_api_key']
|
19
|
+
@@email = @@cfg['dns_cloudflare_email']
|
20
|
+
@@client = CloudflareClient::Zone.new(auth_key: @@api_key, email: @@email)
|
21
|
+
def self.get_certbot_vars
|
22
|
+
@@domain = ENV['CERTBOT_DOMAIN']
|
23
|
+
@@validation = ENV['CERTBOT_VALIDATION']
|
24
|
+
end
|
25
|
+
def self.get_domain
|
26
|
+
domain = ENV['CERTBOT_DOMAIN']
|
27
|
+
@@full_domain = domain
|
28
|
+
@@main_domain = PublicSuffix.domain(domain)
|
29
|
+
end
|
30
|
+
def self.remove_zone_id
|
31
|
+
@@domain_dir = Pathname.new("/sites/tmp/CERTBOT_#{@@domain}")
|
32
|
+
if @@domain_dir.join('ZONE_ID').exist?
|
33
|
+
@@zone_id = File.read(@@domain_dir.join('ZONE_ID').to_s)
|
34
|
+
File.delete(@@domain_dir.join('ZONE_ID').to_s)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def self.remove_record_id
|
38
|
+
if @@domain_dir.join('RECORD_ID').exist?
|
39
|
+
@@record_id = File.read(@@domain_dir.join('RECORD_ID').to_s)
|
40
|
+
File.delete(@@domain_dir.join('RECORD_ID').to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
def self.remove_txt_record
|
44
|
+
unless (defined?(@@zone_id)).nil?
|
45
|
+
unless (defined?(@@record_id)).nil?
|
46
|
+
zone = CloudflareClient::Zone::DNS.new(auth_key: @@api_key, email: @@email, zone_id: @@zone_id)
|
47
|
+
zone.delete(id: @@record_id)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
CleanUp.get_certbot_vars
|
53
|
+
CleanUp.get_domain
|
54
|
+
CleanUp.remove_zone_id
|
55
|
+
CleanUp.remove_record_id
|
56
|
+
CleanUp.remove_txt_record
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'certflare/version'
|
3
|
+
module Certflare
|
4
|
+
class CLI < Thor
|
5
|
+
desc '--version, -v', 'returns version and exits'
|
6
|
+
def __version
|
7
|
+
puts Certflare::VERSION
|
8
|
+
end
|
9
|
+
map ['-v', '--version'] => :__version
|
10
|
+
subcommand('cert', Certflare::Commands::Cert)
|
11
|
+
end
|
12
|
+
class HookCLI < Thor
|
13
|
+
desc '--version, -v', 'returns version and exits'
|
14
|
+
def __version
|
15
|
+
puts Certflare::VERSION
|
16
|
+
end
|
17
|
+
map ['-v', '--version'] => :__version
|
18
|
+
|
19
|
+
desc 'auth [options]', ''
|
20
|
+
def auth
|
21
|
+
# Stub
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'clean [options]', ''
|
25
|
+
def clean
|
26
|
+
# Stub
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019 Ken Spencer / IotaSpencer
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# File: ${FILENAME}
|
6
|
+
# Created: 3/14/19
|
7
|
+
#
|
8
|
+
# License is in project root, MIT License is in use.
|
9
|
+
require 'cloudflare_client'
|
10
|
+
require 'yaml'
|
11
|
+
require 'pathname'
|
12
|
+
require 'public_suffix'
|
13
|
+
|
14
|
+
module Certflare
|
15
|
+
class Authenticator
|
16
|
+
def initialize
|
17
|
+
@cfg = YAML.load_file(Pathname.new('/etc/').join('certflare'))
|
18
|
+
@api_key = @cfg['dns_cloudflare_api_key']
|
19
|
+
@email = @cfg['dns_cloudflare_email']
|
20
|
+
@domain = ENV['CERTBOT_DOMAIN']
|
21
|
+
@validation = ENV['CERTBOT_VALIDATION']
|
22
|
+
@main_domain = PublicSuffix.domain(@domain)
|
23
|
+
zone = CloudflareClient::Zone.new(auth_key: @api_key, email: @email).zones(name: @main_domain)
|
24
|
+
@zone_id = zone[:result][0][:id]
|
25
|
+
|
26
|
+
end
|
27
|
+
def create_txt_record()
|
28
|
+
domain_with_prefix = "_acme-challenge.#{@domain}"
|
29
|
+
# puts "record name: #{domain_with_prefix}"
|
30
|
+
dns_records = CloudflareClient::Zone::DNS.new(zone_id: @zone_id, auth_key: @api_key, email: @email)
|
31
|
+
record = dns_records.create(name: domain_with_prefix, type: 'TXT', content: @validation, ttl: 120)
|
32
|
+
@record_id = record[:result][:id]
|
33
|
+
# puts "record id: #{@@record_id}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_cleanup
|
37
|
+
domain_dir = Pathname.new("/sites/tmp/CERTBOT_#{@domain}")
|
38
|
+
# puts "domain dir: #{domain_dir}"
|
39
|
+
unless domain_dir.exist?
|
40
|
+
Dir.mkdir(domain_dir, 0700)
|
41
|
+
end
|
42
|
+
zone_id_file = domain_dir.join('ZONE_ID')
|
43
|
+
record_id_file = domain_dir.join('RECORD_ID')
|
44
|
+
File.open(zone_id_file, 'w') do |f|
|
45
|
+
f.print(@zone_id)
|
46
|
+
end
|
47
|
+
File.open(record_id_file, 'w') do |f|
|
48
|
+
f.print(@record_id)
|
49
|
+
end
|
50
|
+
# puts <<~HEREDOC
|
51
|
+
# details for #{zone_id_file.to_s}
|
52
|
+
# writable? #{File.writable?(zone_id_file)}
|
53
|
+
# readable? #{File.readable?(zone_id_file)}
|
54
|
+
#HEREDOC
|
55
|
+
#puts <<~HEREDOC
|
56
|
+
# details for #{record_id_file.to_s}
|
57
|
+
# writable? #{File.writable?(record_id_file)}
|
58
|
+
# readable? #{File.readable?(record_id_file)}
|
59
|
+
#HEREDOC
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Authenticator.get_certbot_vars
|
64
|
+
Authenticator.get_domain
|
65
|
+
Authenticator.get_zone_id
|
66
|
+
Authenticator.create_txt_record
|
67
|
+
Authenticator.create_cleanup
|
68
|
+
sleep 20
|
69
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019 Ken Spencer / IotaSpencer
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# File: ${FILENAME}
|
6
|
+
# Created: 3/14/19
|
7
|
+
#
|
8
|
+
# License is in project root, MIT License is in use.
|
9
|
+
require 'cloudflare_client'
|
10
|
+
require 'configparser'
|
11
|
+
require 'pathname'
|
12
|
+
require 'public_suffix'
|
13
|
+
|
14
|
+
module Certflare
|
15
|
+
class CleanUp
|
16
|
+
@@configs_dir = Pathname.new('/sites/configs/dns-cloudflare-credentials/')
|
17
|
+
@@cfg = ConfigParser.new(@@configs_dir.join('cloudflare.ini'))
|
18
|
+
@@api_key = @@cfg['dns_cloudflare_api_key']
|
19
|
+
@@email = @@cfg['dns_cloudflare_email']
|
20
|
+
@@client = CloudflareClient::Zone.new(auth_key: @@api_key, email: @@email)
|
21
|
+
def self.get_certbot_vars
|
22
|
+
@@domain = ENV['CERTBOT_DOMAIN']
|
23
|
+
@@validation = ENV['CERTBOT_VALIDATION']
|
24
|
+
end
|
25
|
+
def self.get_domain
|
26
|
+
domain = ENV['CERTBOT_DOMAIN']
|
27
|
+
@@full_domain = domain
|
28
|
+
@@main_domain = PublicSuffix.domain(domain)
|
29
|
+
end
|
30
|
+
def self.remove_zone_id
|
31
|
+
@@domain_dir = Pathname.new("/sites/tmp/CERTBOT_#{@@domain}")
|
32
|
+
if @@domain_dir.join('ZONE_ID').exist?
|
33
|
+
@@zone_id = File.read(@@domain_dir.join('ZONE_ID').to_s)
|
34
|
+
File.delete(@@domain_dir.join('ZONE_ID').to_s)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def self.remove_record_id
|
38
|
+
if @@domain_dir.join('RECORD_ID').exist?
|
39
|
+
@@record_id = File.read(@@domain_dir.join('RECORD_ID').to_s)
|
40
|
+
File.delete(@@domain_dir.join('RECORD_ID').to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
def self.remove_txt_record
|
44
|
+
unless (defined?(@@zone_id)).nil?
|
45
|
+
unless (defined?(@@record_id)).nil?
|
46
|
+
zone = CloudflareClient::Zone::DNS.new(auth_key: @@api_key, email: @@email, zone_id: @@zone_id)
|
47
|
+
zone.delete(id: @@record_id)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
CleanUp.get_certbot_vars
|
53
|
+
CleanUp.get_domain
|
54
|
+
CleanUp.remove_zone_id
|
55
|
+
CleanUp.remove_record_id
|
56
|
+
CleanUp.remove_txt_record
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
module Certflare
|
3
|
+
class Initialization
|
4
|
+
def initialize
|
5
|
+
@log_dir = Pathname.new('/var').join('log', 'certflare')
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_log_dir
|
9
|
+
unless @log_dir.exist?
|
10
|
+
FileUtils.mkdir_p(Pathname.new('/var').join('log', 'certflare'))
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'yell'
|
2
|
+
require 'yell-adapters-syslog'
|
3
|
+
Yell.new(name: 'CertflareLogger', format: "[%d] (%L) %m") do |l|
|
4
|
+
l.adapter :stdout, level: 'lte.warn', colors: true, name: 'stdout'
|
5
|
+
l.adapter :stderr, level: 'gte.error', colors: true, name: 'stderr'
|
6
|
+
l.adapter :datefile, Pathname('/var').join('log', 'certflare'), colors: true, name: 'logfile'
|
7
|
+
l.adapter :syslog, :facility => :user, :options => [:cons], :ident => 'Certflare'
|
8
|
+
end
|
9
|
+
module Certflare
|
10
|
+
class CertflareLogger
|
11
|
+
include Yell::Loggable
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'certflare'
|
2
|
+
require 'certflare/logger'
|
3
|
+
module Certflare
|
4
|
+
module Runner
|
5
|
+
def initialize(argv = ARGV, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
|
6
|
+
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
class CertflareRunner
|
11
|
+
include Certflare::Runner
|
12
|
+
|
13
|
+
def execute!
|
14
|
+
exit_code = begin
|
15
|
+
$stderr = @stderr
|
16
|
+
$stdin = @stdin
|
17
|
+
$stdout = @stdout
|
18
|
+
Certflare::CLI.start(@argv)
|
19
|
+
0
|
20
|
+
rescue StandardError => e
|
21
|
+
b = e.backtrace
|
22
|
+
STDERR.puts("#{b.shift}: #{e.message} (#{e.class})")
|
23
|
+
STDERR.puts(b.map { |s| "\tfrom #{s}" }.join("\n"))
|
24
|
+
1
|
25
|
+
rescue SystemExit => e
|
26
|
+
STDERR.puts e.status
|
27
|
+
1
|
28
|
+
ensure
|
29
|
+
$stderr = STDERR
|
30
|
+
$stdin = STDIN
|
31
|
+
$stdout = STDOUT
|
32
|
+
end
|
33
|
+
@kernel.exit(exit_code)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
class CertflareHookRunner
|
37
|
+
include Runner
|
38
|
+
def execute!
|
39
|
+
exit_code = begin
|
40
|
+
$stderr = @stderr
|
41
|
+
$stdin = @stdin
|
42
|
+
$stdout = @stdout
|
43
|
+
Certflare::HookCLI.start(@argv)
|
44
|
+
0
|
45
|
+
rescue StandardError => e
|
46
|
+
b = e.backtrace
|
47
|
+
STDERR.puts("#{b.shift}: #{e.message} (#{e.class})")
|
48
|
+
STDERR.puts(b.map { |s| "\tfrom #{s}" }.join("\n"))
|
49
|
+
1
|
50
|
+
rescue SystemExit => e
|
51
|
+
STDERR.puts e.status
|
52
|
+
1
|
53
|
+
ensure
|
54
|
+
$stderr = STDERR
|
55
|
+
$stdin = STDIN
|
56
|
+
$stdout = STDOUT
|
57
|
+
end
|
58
|
+
@kernel.exit(exit_code)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/lib/certflare.rb
ADDED
metadata
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: certflare
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ken Spencer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: acme-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cloudflare_client_rb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: configparser
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: public_suffix
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.20.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.20.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yell
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.1.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yell-adapters-syslog
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.0.2
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.0.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.16'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.16'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '10.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '10.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: memfs
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.0.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.0.0
|
181
|
+
description:
|
182
|
+
email:
|
183
|
+
- me@iotaspencer.me
|
184
|
+
executables:
|
185
|
+
- certflare
|
186
|
+
- certflare_hook
|
187
|
+
extensions: []
|
188
|
+
extra_rdoc_files: []
|
189
|
+
files:
|
190
|
+
- ".gitignore"
|
191
|
+
- ".rspec"
|
192
|
+
- ".travis.yml"
|
193
|
+
- CODE_OF_CONDUCT.md
|
194
|
+
- Gemfile
|
195
|
+
- LICENSE.txt
|
196
|
+
- README.md
|
197
|
+
- Rakefile
|
198
|
+
- bin/certflare
|
199
|
+
- bin/certflare_hook
|
200
|
+
- certflare.gemspec
|
201
|
+
- lib/certflare.rb
|
202
|
+
- lib/certflare/cleanup.rb
|
203
|
+
- lib/certflare/cli.rb
|
204
|
+
- lib/certflare/commands/cert.rb
|
205
|
+
- lib/certflare/common/authenticator.rb
|
206
|
+
- lib/certflare/common/cleanup.rb
|
207
|
+
- lib/certflare/initialization.rb
|
208
|
+
- lib/certflare/logger.rb
|
209
|
+
- lib/certflare/runner.rb
|
210
|
+
- lib/certflare/version.rb
|
211
|
+
homepage: https://iotaspencer.me/projects/certflare/
|
212
|
+
licenses:
|
213
|
+
- MIT
|
214
|
+
metadata: {}
|
215
|
+
post_install_message:
|
216
|
+
rdoc_options: []
|
217
|
+
require_paths:
|
218
|
+
- lib
|
219
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
requirements: []
|
230
|
+
rubyforge_project:
|
231
|
+
rubygems_version: 2.7.6
|
232
|
+
signing_key:
|
233
|
+
specification_version: 4
|
234
|
+
summary: This summary is a summary of a summary
|
235
|
+
test_files: []
|