Sha256: 167f15d2ff63ecd7ff4035f110e1e5c5f9505c3a379c6605e017d74d02491204

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Dyndnsd
  module Updater
    class CommandWithBindZone
      # @param domain [String]
      # @param updater_params [Hash{String => Object}]
      def initialize(domain, updater_params)
        @zone_file = updater_params['zone_file']
        @command = updater_params['command']
        @generator = Generator::Bind.new(domain, updater_params)
      end

      # @param db [Dyndnsd::Database]
      # @return [void]
      def update(db)
        # do not regenerate zone file (assumed to be persistent) if DB did not change
        return if !db.changed?

        Helper.span('updater_update') do |span|
          span.set_attribute('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')

          # write zone file in bind syntax
          File.write(@zone_file, @generator.generate(db))
          # call user-defined command
          pid = fork do
            exec @command
          end

          # detach so children don't become zombies
          Process.detach(pid) if pid
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dyndnsd-3.10.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.9.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.9.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.9.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.8.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.8.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.8.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.7.3 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.7.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.7.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.7.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.6.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.6.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.6.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.5.3 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.5.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.5.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.5.0 lib/dyndnsd/updater/command_with_bind_zone.rb