Commit 6bd6f2be authored by telyn's avatar telyn
Browse files

Implement symbiosis-ssl hooks

parent ad35a2ad
......@@ -177,6 +177,8 @@ end
now = Time.now
domains_altered = []
domains.sort_by(&:name).each do |domain|
if do_list || rollover_to
puts "Certificate sets for #{domain}:"
......@@ -218,7 +220,8 @@ domains.sort_by(&:name).each do |domain|
end
begin
domain.ssl_magic(threshold, do_generate, do_rollover, now)
rollover_performed = domain.ssl_magic(threshold, do_generate, do_rollover, now)
domains_altered.push domain.name if rollover_performed
rescue StandardError => err
puts "\t!! Failed: #{err.to_s.gsub($RS, '')}" if $VERBOSE
puts err.backtrace.join("\n") if $DEBUG
......@@ -226,4 +229,6 @@ domains.sort_by(&:name).each do |domain|
end
end
Symbiosis::SSL.call_hooks domains_altered
exit exit_code
......@@ -397,6 +397,9 @@ module Symbiosis
# * generation
# * rollover
#
# Why does it do all these things?
#
# Returns true if a rollover was performed, or false otherwise.
def ssl_magic(threshold = 14, do_generate = nil, do_rollover = nil, now = Time.now)
puts "* Examining certificates for #{self.name}" if $VERBOSE
......@@ -464,7 +467,7 @@ module Symbiosis
else
puts "\tNo valid certificate sets found." if $VERBOSE
do_generate = true if do_generate.nil?
do_generate = true if do_generate.nil?
end
......
module Symbiosis
class SSL
PROVIDERS ||= []
def self.call_hooks(domains_with_updates)
return if domains_with_updates.empty?
Dir.glob('/etc/symbiosis/ssl-hooks.d/*').each do |script|
next unless File.executable?(script)
IO.popen([script, 'live-update'], 'r+') do |io|
io.puts domains_with_updates.join("\n")
io.close_write # Close the pipe now we've written stuff.
end
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment