ssl.rb 664 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
9
10

    def self.call_hooks(domains_with_updates)
      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) =~ /\..*$/
telyn's avatar
telyn committed
16
17
18
19
20
21
        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
22
23
  end
end