mirror of
https://github.com/casjaysdevdocker/bind
synced 2024-11-22 05:23:09 -05:00
🗃️ Committing everything that changed 🗃️
rootfs/tmp/etc/bind/named.conf rootfs/usr/local/etc/docker/init.d/00-named.sh
This commit is contained in:
parent
160a0daa7c
commit
d175b3919b
@ -86,3 +86,4 @@ zone "." {
|
|||||||
# ********** end root info **********
|
# ********** end root info **********
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# begin imports
|
# begin imports
|
||||||
|
include "REPLACE_ETC_DIR/zones.conf";
|
||||||
|
@ -188,7 +188,7 @@ CMD_ENV=""
|
|||||||
[ -f "$CONF_DIR/secrets/certbot.key" ] && KEY_CERTBOT="$(<"$CONF_DIR/secrets/certbot.key")"
|
[ -f "$CONF_DIR/secrets/certbot.key" ] && KEY_CERTBOT="$(<"$CONF_DIR/secrets/certbot.key")"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Per Application Variables or imports
|
# Per Application Variables or imports
|
||||||
|
[ -f "$CONF_DIR/named.conf" ] && NAMED_CONFIG_FILE="$CONF_DIR/named.conf" && NAMED_CONFIG_COPY="yes" || NAMED_CONFIG_FILE="$ETC_DIR/named.conf"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Custom commands to run before copying to /config
|
# Custom commands to run before copying to /config
|
||||||
__run_precopy() {
|
__run_precopy() {
|
||||||
@ -249,26 +249,26 @@ __update_conf_files() {
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# replace variables
|
# replace variables
|
||||||
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$ETC_DIR/rndc.key"
|
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$ETC_DIR/rndc.key"
|
||||||
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$ETC_DIR/named.conf"
|
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$NAMED_CONFIG_FILE"
|
||||||
__replace "REPLACE_KEY_DHCP" "$KEY_DHCP" "$ETC_DIR/named.conf"
|
__replace "REPLACE_KEY_DHCP" "$KEY_DHCP" "$NAMED_CONFIG_FILE"
|
||||||
__replace "REPLACE_KEY_BACKUP" "$KEY_BACKUP" "$ETC_DIR/named.conf"
|
__replace "REPLACE_KEY_BACKUP" "$KEY_BACKUP" "$NAMED_CONFIG_FILE"
|
||||||
__replace "REPLACE_KEY_CERTBOT" "$KEY_CERTBOT" "$ETC_DIR/named.conf"
|
__replace "REPLACE_KEY_CERTBOT" "$KEY_CERTBOT" "$NAMED_CONFIG_FILE"
|
||||||
__replace "REPLACE_DNS_SERVER_SECONDARY" "$DNS_SERVER_SECONDARY" "$ETC_DIR/named.conf"
|
__replace "REPLACE_DNS_SERVER_SECONDARY" "$DNS_SERVER_SECONDARY" "$NAMED_CONFIG_FILE"
|
||||||
|
|
||||||
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$CONF_DIR/rndc.key"
|
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$CONF_DIR/rndc.key"
|
||||||
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$CONF_DIR/named.conf"
|
__replace "REPLACE_KEY_RNDC" "$KEY_RNDC" "$CONF_DIR/named.conf"
|
||||||
__replace "REPLACE_KEY_DHCP" "$KEY_DHCP" "$CONF_DIR/named.conf"
|
__replace "REPLACE_KEY_DHCP" "$KEY_DHCP" "$CONF_DIR/named.conf"
|
||||||
__replace "REPLACE_KEY_BACKUP" "$KEY_BACKUP" "$CONF_DIR/named.conf"
|
__replace "REPLACE_KEY_BACKUP" "$KEY_BACKUP" "$CONF_DIR/named.conf"
|
||||||
__replace "REPLACE_KEY_CERTBOT" "$KEY_CERTBOT" "$CONF_DIR/named.conf"
|
__replace "REPLACE_KEY_CERTBOT" "$KEY_CERTBOT" "$CONF_DIR/named.conf"
|
||||||
__replace "REPLACE_DNS_SERVER_SECONDARY" "$DNS_SERVER_SECONDARY" "$ETC_DIR/named.conf"
|
__replace "REPLACE_DNS_SERVER_SECONDARY" "$DNS_SERVER_SECONDARY" "$NAMED_CONFIG_FILE"
|
||||||
__replace "REPLACE_DNS_SERIAL" "$DNS_SERIAL" "$DATA_DIR/primary"
|
__replace "REPLACE_DNS_SERIAL" "$DNS_SERIAL" "$DATA_DIR/primary"
|
||||||
__replace "REPLACE_DNS_SERIAL" "$DNS_SERIAL" "$DATA_DIR/secondary"
|
__replace "REPLACE_DNS_SERIAL" "$DNS_SERIAL" "$DATA_DIR/secondary"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# define actions
|
# define actions
|
||||||
if [ -f "$CONF_DIR/custom.conf" ]; then
|
if [ -f "$CONF_DIR/custom.conf" ]; then
|
||||||
mv -f "$CONF_DIR/custom.conf" "$ETC_DIR/named.conf"
|
mv -f "$CONF_DIR/custom.conf" "$NAMED_CONFIG_FILE"
|
||||||
elif [ -f "$ETC_DIR/custom.conf" ]; then
|
elif [ -f "$ETC_DIR/custom.conf" ]; then
|
||||||
mv -f "$ETC_DIR/custom.conf" "$ETC_DIR/named.conf"
|
mv -f "$ETC_DIR/custom.conf" "$NAMED_CONFIG_FILE"
|
||||||
fi
|
fi
|
||||||
[ -n "$KEY_RNDC" ] && echo "$KEY_RNDC" >"$CONF_DIR/secrets/rndc.key"
|
[ -n "$KEY_RNDC" ] && echo "$KEY_RNDC" >"$CONF_DIR/secrets/rndc.key"
|
||||||
[ -n "$KEY_DHCP" ] && echo "$KEY_DHCP" >"$CONF_DIR/secrets/dhcp.key"
|
[ -n "$KEY_DHCP" ] && echo "$KEY_DHCP" >"$CONF_DIR/secrets/dhcp.key"
|
||||||
@ -286,9 +286,9 @@ __pre_execute() {
|
|||||||
# __is_dir_empty "$CONF_DIR" && true
|
# __is_dir_empty "$CONF_DIR" && true
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# define actions to run after copying to /config
|
# define actions to run after copying to /config
|
||||||
zone_files="$(find "$data_dir/zones/" -type f | wc -l)"
|
zone_files="$(find "$DATA_DIR/zones/" -type f | wc -l)"
|
||||||
if [ $zone_files = 0 ] && [ ! -f "$DATA_DIR/primary/$HOSTNAME.zone" ]; then
|
if [ $zone_files = 0 ] && [ ! -f "$VAR_DIR/primary/$HOSTNAME.zone" ]; then
|
||||||
cat <<EOF >>"$ETC_DIR/named.conf"
|
cat <<EOF >>"$ETC_DIR/zones.conf"
|
||||||
# ********** begin $HOSTNAME **********
|
# ********** begin $HOSTNAME **********
|
||||||
zone "$HOSTNAME" {
|
zone "$HOSTNAME" {
|
||||||
type master;
|
type master;
|
||||||
@ -301,7 +301,7 @@ zone "$HOSTNAME" {
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF | tee "$DATA_DIR/primary/$HOSTNAME.zone" &>/dev/null
|
cat <<EOF | tee "$VAR_DIR/primary/$HOSTNAME.zone" &>/dev/null
|
||||||
; config for $HOSTNAME
|
; config for $HOSTNAME
|
||||||
@ IN SOA $HOSTNAME. root.$HOSTNAME. ( $DNS_SERIAL 10800 3600 1209600 38400)
|
@ IN SOA $HOSTNAME. root.$HOSTNAME. ( $DNS_SERIAL 10800 3600 1209600 38400)
|
||||||
IN NS $HOSTNAME.
|
IN NS $HOSTNAME.
|
||||||
@ -314,10 +314,10 @@ EOF
|
|||||||
file_name="$(basename "$dns_file")"
|
file_name="$(basename "$dns_file")"
|
||||||
domain_name="$(grep -Rs '\$ORIGIN' "$dns_file" | awk '{print $NF}' | sed 's|.$||g')"
|
domain_name="$(grep -Rs '\$ORIGIN' "$dns_file" | awk '{print $NF}' | sed 's|.$||g')"
|
||||||
if [ -f "$dns_file" ]; then
|
if [ -f "$dns_file" ]; then
|
||||||
if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$ETC_DIR/named.conf"; then
|
if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$NAMED_CONFIG_FILE"; then
|
||||||
if [ "$DNS_TYPE" = "secondary" ]; then
|
if [ "$DNS_TYPE" = "secondary" ]; then
|
||||||
[ -f "$VAR_DIR/secondary/$file_name" ] || echo "" >"$VAR_DIR/secondary/$file_name"
|
[ -f "$VAR_DIR/secondary/$file_name" ] || echo "" >"$VAR_DIR/secondary/$file_name"
|
||||||
cat <<EOF >>"$ETC_DIR/named.conf"
|
cat <<EOF >>"$ETC_DIR/zones.conf"
|
||||||
# ********** begin $domain_name **********
|
# ********** begin $domain_name **********
|
||||||
zone "$domain_name" {
|
zone "$domain_name" {
|
||||||
type slave;
|
type slave;
|
||||||
@ -329,7 +329,7 @@ zone "$domain_name" {
|
|||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cp -Rf "$dns_file" "$VAR_DIR/primary/$file_name"
|
cp -Rf "$dns_file" "$VAR_DIR/primary/$file_name"
|
||||||
cat <<EOF >>"$ETC_DIR/named.conf"
|
cat <<EOF >>"$ETC_DIR/zones.conf"
|
||||||
# ********** begin $domain_name **********
|
# ********** begin $domain_name **********
|
||||||
zone "$domain_name" {
|
zone "$domain_name" {
|
||||||
type master;
|
type master;
|
||||||
@ -343,17 +343,17 @@ zone "$domain_name" {
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
grep -qs "$domain_name" "$ETC_DIR/named.conf" && echo "Added $domain_name to $ETC_DIR/named.conf"
|
grep -qs "$domain_name" "$NAMED_CONFIG_FILE" "$ETC_DIR/zones.conf" && echo "Added $domain_name to $NAMED_CONFIG_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if named-checkconf -z $ETC_DIR/named.conf &>/dev/null; then
|
if named-checkconf -z $NAMED_CONFIG_FILE &>/dev/null; then
|
||||||
echo "named-checkconf has succeeded"
|
echo "named-checkconf has succeeded"
|
||||||
else
|
else
|
||||||
echo "named-checkconf has failed:"
|
echo "named-checkconf has failed:"
|
||||||
named-checkconf -z $ETC_DIR/named.conf
|
named-checkconf -z $NAMED_CONFIG_FILE
|
||||||
fi
|
fi
|
||||||
|
[ "$NAMED_CONFIG_COPY" = "yes" ] && cp -Rf "$NAMED_CONFIG_FILE" "$ETC_DIR/named.conf" || cp -Rf "$NAMED_CONFIG_FILE" "$CONF_DIR/named.conf"
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# unset unneeded variables
|
# unset unneeded variables
|
||||||
# unset
|
# unset
|
||||||
|
Loading…
Reference in New Issue
Block a user