2013-04-27 14:07:14 +02:00
|
|
|
|
|
|
|
module Dyndnsd
|
|
|
|
module Updater
|
|
|
|
class CommandWithBindZone
|
2013-04-27 15:08:36 +02:00
|
|
|
def initialize(domain, config)
|
2013-04-27 14:07:14 +02:00
|
|
|
@zone_file = config['zone_file']
|
|
|
|
@command = config['command']
|
2013-04-27 15:08:36 +02:00
|
|
|
@generator = Generator::Bind.new(domain, config)
|
2013-04-27 14:07:14 +02:00
|
|
|
end
|
2018-02-23 12:54:43 +01:00
|
|
|
|
2013-04-27 14:07:14 +02:00
|
|
|
def update(zone)
|
2018-01-26 16:25:15 +01:00
|
|
|
Helper.span('updater_update') do |span|
|
|
|
|
span.set_tag('dyndnsd.updater.name', self.class.name.split('::').last)
|
|
|
|
|
|
|
|
# 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)
|
2013-04-27 14:07:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|