Sha256: efce0d645cb63051c8500c45dcac13c479f5f0c44d7743e45c90648593946edd

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 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_tag('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')

          # write zone file in bind syntax
          File.open(@zone_file, 'w') { |f| f.write(@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

16 entries across 16 versions & 1 rubygems

Version Path
dyndnsd-3.4.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.4.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.3.3 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.3.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.3.2.rc1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.3.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.3.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.2.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.1.3 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.1.2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.1.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.1.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.1.0.rc1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-3.0.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-2.3.1 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-2.3.0 lib/dyndnsd/updater/command_with_bind_zone.rb