From 009dcb0da728067c963202a1511fa6d34931b915 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Wed, 28 Jun 2023 15:22:23 +0200 Subject: [PATCH] Add a template directory for new domain templates. --- src/config.cr | 6 ++++++ src/main.cr | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/config.cr b/src/config.cr index 4f32eae..2f75706 100644 --- a/src/config.cr +++ b/src/config.cr @@ -7,6 +7,12 @@ class Baguette::Configuration property recreate_indexes : Bool = false property storage_directory : String = "storage" + # New domains require to load a template so the user won't have to enter some + # necessary entries himself. For example, SOA and NS RRs should be pre-loaded + # and updated by an administrator when required. + # See tools/write-template-zone-file.cr + property template_directory : String = "/etc/dnsmanager/templates" + def initialize end end diff --git a/src/main.cr b/src/main.cr index a04a107..17335e5 100644 --- a/src/main.cr +++ b/src/main.cr @@ -201,6 +201,18 @@ def main end end + unless File.directory? configuration.template_directory + Baguette::Log.warning "template directory '#{configuration.template_directory}' doesn't exist" + if File.directory? "./templates" + Baguette::Log.info "using template directory './templates'" + configuration.template_directory = "./templates" + else + Baguette::Log.error "tried template directory './templates', but doesn't exist either" + Baguette::Log.error "no template directory detected, quitting" + exit 1 + end + end + if simulation pp! configuration exit 0