Commit 4b4f0b26 authored by Colin Shea's avatar Colin Shea

change things to be more local paths

parent 0e7fd1e9
......@@ -2,6 +2,11 @@
require_relative '../lib/environment'
generator = ZoneGenerator.new "#{__dir__}/.."
# Create a temp directory for the workspace if it doesn't exist already
if !File.directory? File.join(Dir.pwd, 'tmp')
Dir.mkdir('tmp')
end
generator = ZoneGenerator.new Dir.pwd
generator.generate
generator.deploy
named_conf: ./pdns_zones
zones_dir: ./output
# PowerDNS paths
named_conf: /etc/powerdns/named.conf
zones_dir: /var/lib/powerdns/zones
ruby_zones: ./zones/
templates: ./templates/
# Command to run after push
execute: '/usr/bin/pdns_control reload'
execute: '/bin/echo happy'
# SOA Record
# Recommendations: http://www.ripe.net/ripe/docs/ripe-203
......
......@@ -3,14 +3,11 @@ class ZoneGenerator
def initialize(basedir)
@generated = "#{basedir}/tmp/generated"
@workspace = "#{basedir}/tmp/cache"
@zones_dir = "#{@workspace}/zones"
@template_dir = "#{@workspace}/templates"
@tmp_named = "#{@generated}/named.conf"
@tmp_zones = "#{@generated}/zones"
@config = YAML.load_file("#{@workspace}/config.yaml")
@config = YAML.load_file("config.yaml")
@config.deep_symbolize_keys!
@soa = {
origin: "@",
......@@ -23,13 +20,17 @@ class ZoneGenerator
minimumTTL: "11h"
}.merge(@config[:soa])
@zones_dir = File.expand_path(@config[:ruby_zones])
@template_dir = File.expand_path(@config[:templates])
# Rewrite email address
if (email = @soa[:email]).include?("@")
@soa[:email] = email.sub("@",".") << "."
end
FileUtils.rm_rf @generated # Tote Zonen-Definitionen brauchen wir nicht.
FileUtils.rm_rf @generated
FileUtils.mkdir_p @generated
FileUtils.mkdir_p @tmp_zones
end
# Generates all zones
......@@ -37,6 +38,7 @@ class ZoneGenerator
File.open(@tmp_named,"w") do |f|
Dir.glob("#{@zones_dir}/**/*.rb").sort.each do |file|
domain = File.basename(file).sub(/\.rb$/,"")
puts "Generating zone for '#{domain}'"
generate_zone(file, domain)
f.puts "zone \"#{domain}\" IN { type master; file \"#{@config[:zones_dir]}/#{domain}\"; };"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment