ssl.rb 663 Bytes
Newer Older
telyn's avatar
telyn committed
1
2
require 'symbiosis'

3
module Symbiosis
telyn's avatar
telyn committed
4
  # SSL knows about which SSL providers exist and provides SSL helper functions
5
  class SSL
6
    PROVIDERS ||= []
telyn's avatar
telyn committed
7

8
    def self.call_hooks(domains_with_updates, event)
telyn's avatar
telyn committed
9
10
      return if domains_with_updates.empty?

11
      hooks_path = Symbiosis.path_in_etc('/symbiosis/ssl-hooks.d/*')
telyn's avatar
telyn committed
12
13

      Dir.glob(hooks_path).each do |script|
telyn's avatar
telyn committed
14
        next unless File.executable?(script)
telyn's avatar
telyn committed
15
        next if File.basename(script) =~ /\..*$/
16
        IO.popen([script, event], 'r+') do |io|
telyn's avatar
telyn committed
17
18
19
20
21
          io.puts domains_with_updates.join("\n")
          io.close_write # Close the pipe now we've written stuff.
        end
      end
    end
22
23
  end
end