- populated = template % {hostname:hostname, uuid_prefix:@@uuid_prefix, ip_address:ip_address, ptr_domain:ptr_domain}
+ if Rails.configuration.dns_server_conf_dir and Rails.configuration.dns_server_conf_template
+ begin
+ begin
+ template = IO.read(Rails.configuration.dns_server_conf_template)
+ rescue => e
+ logger.error "Reading #{Rails.configuration.dns_server_conf_template}: #{e.message}"
+ raise
+ end
+
+ hostfile = File.join Rails.configuration.dns_server_conf_dir, "#{hostname}.conf"
+ File.open hostfile+'.tmp', 'w' do |f|
+ f.puts template % template_vars
+ end
+ File.rename hostfile+'.tmp', hostfile
+ rescue => e
+ logger.error "Writing #{hostfile}: #{e.message}"
+ ok = false
+ end
+ end