Switch everything to Python

This commit is contained in:
2025-08-27 23:51:18 +02:00
parent f38b2f35ff
commit f57890f6c9
15 changed files with 1470 additions and 1094 deletions

View File

@@ -1,82 +0,0 @@
#!/usr/bin/env bash
####################
## Global options ##
####################
#
# Paths to external binaries
#
#DIG="/usr/bin/dig"
#IDN2="/usr/bin/idn2"
#JQ="/usr/bin/jq"
#NAMED_CHECKCONF="/usr/bin/named-checkconf"
#NSUPDATE="/usr/bin/nsupdate"
#RNDC="/usr/sbin/rndc"
#
# Path to library directory
#
#LIB_DIR="/usr/local/dns-manager/lib"
#
# Color of the header text when printing tables
#
#TABLE_HEADER_COLOR="red"
#TERMINAL_WITH=$(/usr/bin/tput cols)
##############################
## Options for DDNS updates ##
##############################
#
# IP address of the DNS server (default is 127.0.0.1)
#
#DNS_IP="127.0.0.1"
#
# Associative array of paths to key files (TSIG) per view used for zone transfers
# and DDNS updates. This option mandatory when using views other than the default view.
# The keys have to be in one of these forms:
# - VIEW
# - ZONE@VIEW
#
#declare -A DNS_KEYS=(
# [_default]="/etc/bind/rndc.key"
#)
#######################################
## Options for adding/removing zones ##
#######################################
#
# Optional control key used to run "rndc reconfig" after adding or deleting zones.
# Otherwise the rndc default key is used.
#
#CONTROL_KEY="/etc/bind/rndc.key"
#
# Associative array of directories and config files per view. This option is mandatory when adding
# or removing zones. The syntax of the value is:
# ZONEDIR:CONFDIR:CFGFILE
#
# Zone files are stored in ZONEDIR and config files are stored in CONFDIR.
# The content of all config files in CONFDIR are concatenated and written to CFGFILE which
# has to be included by "named.conf".
# The detour via CONFDIR is necessary because Bind does not support wildcards when
# including config files.
#
#declare -A BASE_CONFIG=(
# [_default]="/etc/bind/dyn:/etc/dns-manager/default.zones:/etc/bind/default_zones.conf"
#)
#
# Optional associative array of templates per view used when adding new zones.
# The syntax of the value is:
# ZONE_TEMPLATE:CONF_TEMPLATE
#
#declare -A ZONE_TEMPLATES=(
# [_default]="/etc/dns-manager/templates/zone.template:/etc/dns-manager/templates/zone.config.template"
#)

88
etc/config.yml Normal file
View File

@@ -0,0 +1,88 @@
#
# Optional path to config directory (default: /etc/dns-manager).
#
#etc_dir: /etc/dns-manager
#
# Optional paths to named_checkconf and rndc binaries.
#
#named_checkconf: /usr/bin/named-checkconf
#rndc: /usr/bin/rndc
#
# Optional path to named.conf.
#
#named_conf: /etc/bind/named.conf
#
# Optional IP address of the DNS server (default: 127.0.0.1).
#
#dns_ip: 127.0.0.1
#
# Dictionary of paths to key files (TSIG) per view used for zone transfers and DDNS updates.
# This option is mandatory when using views other than the default (_default) or if the usage of a key
# is mandatory to transfer and/or update zones. The keys of this dictionary are either the name of a view
# or a specific zone in a view (zone@view).
# Keep in mind that the first key found in the key files is used and all other keys are ignored.
#
#dns_keyfiles:
# _default: /etc/bind/rndc.key
# example.tld@_default: /etc/bind/another.key
#
# Optional path to key file passed to rndc (-k option), otherwise rndc uses its default key file.
# This key is used to reconfigure Bind when adding or deleting zones.
#
#control_key: /etc/bind/rndc.key
#
# Dictionary of configuration options per view.
#
zones_config:
_default:
#
# Optional path to directory where config files per zone are stored.
# Default: <etc_dir>/<view>.zones
#
#config_dir: /etc/dns-manager/_default.zones
#
# Path to config file that has to be included in named.conf.
# All configs stored in <config_dir> will be concatenated and written to it. The detour via this file is necessary
# because Bind does not support wildcards when including config files.
#
config_file: /etc/bind/default_zones.conf
#
# Path to the directory where the Bind zone files of this view are stored.
# This is typically "/etc/bind/dyn" in an single view environment.
#
zone_dir: /etc/bind/dyn
#
# Optional Bind catalog zone that will be managed automatically when adding or deleting zones.
# The view may also be specified if necessary (zone@view). It is
#
# IMPORTANT: It is recommended to manually add catalog zones to Bind to prevent accidental deletion.
#
#catalog_zone: catalog.example.tld
#
# Optional paths to config and zone default templates used when adding zones.
#
#templates:
# config: /etc/dns-manager/templates/zone.config.template
# zone: /etc/dns-manager/templates/zone.template

View File

@@ -2,10 +2,10 @@ zone "%ZONE%" {
type master;
file "%ZONE_FILE%";
update-policy {
grant dns-manager-key zonesub any;
grant rndc-key zonesub any;
};
allow-transfer {
key dns-manager-key;
key rndc-key;
};
};

View File

@@ -1,5 +1,5 @@
$TTL 86400 ; 1 day
@ IN SOA dns1.%ZONE%. hostmaster.%ZONE%. (
%ZONE%. IN SOA dns1.%ZONE%. hostmaster.%ZONE%. (
1 ; serial
10800 ; refresh (3 hours)
3600 ; retry (1 hour)
@@ -8,3 +8,4 @@ $TTL 86400 ; 1 day
)
NS dns1.%ZONE%.
NS dns2.%ZONE%.
$ORIGIN %ZONE%.