Commit 84d44920 authored by telyn's avatar telyn
Browse files

symbiosis-ssl now returns an error code if any of the hooks do not succeed

parent c652b5ac
......@@ -237,6 +237,7 @@ domains.sort_by(&:name).each do |domain|
end
end
Symbiosis::SSL.call_hooks domains_altered, 'live-update'
success = Symbiosis::SSL.call_hooks domains_altered, 'live-update'
exit_code = 2 unless success
exit exit_code
require 'symbiosis'
require 'open3'
module Symbiosis
# SSL knows about which SSL providers exist and provides SSL helper functions
......@@ -6,18 +7,29 @@ module Symbiosis
PROVIDERS ||= []
def self.call_hooks(domains_with_updates, event)
return if domains_with_updates.empty?
hooks_path = Symbiosis.path_in_etc('/symbiosis/ssl-hooks.d/*')
success = true
Dir.glob(hooks_path).each do |script|
next unless File.executable?(script)
next if File.basename(script) =~ /\..*$/
IO.popen([script, event], 'r+') do |io|
io.puts domains_with_updates.join("\n")
io.close_write # Close the pipe now we've written stuff.
end
next if File.basename(script) =~ /^[a-zA-Z0-9_-]+$/
success &&= run_hook_script(event, script, domains_with_updates)
end
success
end
def self.run_hook_script(event, script, domains_with_updates)
opts = { stdin_data: domains_with_updates.join("\n") }
output, status = Open3.capture2e([script, event], opts)
return true if status.success?
puts "============================================\n"
puts "Error executing SSL script for #{event} hook\n"
puts "#{script} exited with status #{status.exitstatus}\n"
puts output + "\n\n"
false
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