Class: Dyndnsd::Updater::CommandWithBindZone

Inherits:
Object
  • Object
show all
Defined in:
lib/dyndnsd/updater/command_with_bind_zone.rb

Instance Method Summary collapse

Constructor Details

#initialize(domain, config) ⇒ CommandWithBindZone

Returns a new instance of CommandWithBindZone.



5
6
7
8
9
# File 'lib/dyndnsd/updater/command_with_bind_zone.rb', line 5

def initialize(domain, config)
  @zone_file = config['zone_file']
  @command = config['command']
  @generator = Generator::Bind.new(domain, config)
end

Instance Method Details

#update(zone) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/dyndnsd/updater/command_with_bind_zone.rb', line 11

def update(zone)
  # write zone file in bind syntax
  File.open(@zone_file, 'w') { |f| f.write(@generator.generate(zone)) }
  # call user-defined command
  pid = fork do
    exec @command
  end
  # detach so children don't become zombies
  Process.detach(pid)
end