🗃️ Committing everything that changed 🗃️

rootfs/root/docker/setup/03-files.sh
rootfs/usr/local/etc/docker/init.d/00-named.sh
This commit is contained in:
casjay 2024-08-27 12:12:13 -04:00
parent 2aacad4d0c
commit bf9dfb8166
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145
2 changed files with 27 additions and 8 deletions

View File

@ -64,7 +64,10 @@ fi
unset config unset config
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
rm -Rf /etc/bind /etc/named /var/bind /var/named rm -Rf /etc/bind.* /etc/named.*
rm -Rf "/etc/bind"/* "/var/bind"/*
rm -Rf "/etc/named"/* "/var/named"/*
mkdir -p "/etc/bind/keys" "/var/bind/zones" "/var/bind/primary" "/var/bind/secondary" "/var/bind/stats" "/var/bind/dynamic"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? exitCode=$?

View File

@ -240,7 +240,8 @@ __update_conf_files() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# custom commands # custom commands
mkdir -p "$ETC_DIR/keys" "$CONF_DIR/keys" "$CONF_DIR/secrets" "$VAR_DIR/zones" "$VAR_DIR/slaves" "$DATA_DIR/zones" "$DATA_DIR/stats" mkdir -p "$CONF_DIR/keys" "$CONF_DIR/secrets"
mkdir -p "$ETC_DIR/keys" "$DATA_DIR/primary" "$DATA_DIR/secondary" "$DATA_DIR/stats" "$DATA_DIR/dynamic"
for logfile in xfer update notify querylog default debug security; do for logfile in xfer update notify querylog default debug security; do
touch "$LOG_DIR/$logfile.log" touch "$LOG_DIR/$logfile.log"
chmod -Rf 777 "$logfile" chmod -Rf 777 "$logfile"
@ -260,6 +261,8 @@ __update_conf_files() {
__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" "$ETC_DIR/named.conf"
__replace "REPLACE_DNS_SERIAL" "$DNS_SERIAL" "$DATA_DIR/primary"
__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
@ -284,8 +287,21 @@ __pre_execute() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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/zones/$HOSTNAME.zone" ]; then if [ $zone_files = 0 ] && [ ! -f "$DATA_DIR/primary/$HOSTNAME.zone" ]; then
cat <<EOF | tee "$DATA_DIR/zones/$HOSTNAME.zone" &>/dev/null cat <<EOF >>"$ETC_DIR/named.conf"
# ********** begin $HOSTNAME **********
zone "$HOSTNAME" {
type master;
notify yes;
allow-transfer { any; key "backup-key"; trusted; };
allow-update {key "certbot."; key "dhcp-key"; trusted; };
file "$VAR_DIR/primary/$file_name";
};
# ********** end $HOSTNAME **********
EOF
cat <<EOF | tee "$DATA_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.
@ -298,21 +314,21 @@ 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
cp -Rf "$dns_file" "$VAR_DIR/zones/$file_name"
if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$ETC_DIR/named.conf"; then if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$ETC_DIR/named.conf"; then
if [ "$DNS_TYPE" = "secondary" ]; then if [ "$DNS_TYPE" = "secondary" ]; then
echo "" >"$VAR_DIR/slaves/$file_name" [ -f "$VAR_DIR/secondary/$file_name" ] || echo "" >"$VAR_DIR/secondary/$file_name"
cat <<EOF >>"$ETC_DIR/named.conf" cat <<EOF >>"$ETC_DIR/named.conf"
# ********** begin $domain_name ********** # ********** begin $domain_name **********
zone "$domain_name" { zone "$domain_name" {
type slave; type slave;
masters { $DNS_SERVER_PRIMARY; }; masters { $DNS_SERVER_PRIMARY; };
file "$VAR_DIR/slaves/$file_name"; file "$VAR_DIR/secondary/$file_name";
}; };
# ********** end $domain_name ********** # ********** end $domain_name **********
EOF EOF
else else
cp -Rf "$dns_file" "$VAR_DIR/primary/$file_name"
cat <<EOF >>"$ETC_DIR/named.conf" cat <<EOF >>"$ETC_DIR/named.conf"
# ********** begin $domain_name ********** # ********** begin $domain_name **********
zone "$domain_name" { zone "$domain_name" {
@ -321,7 +337,7 @@ zone "$domain_name" {
also-notify { $DNS_SERVER_SECONDARY; }; also-notify { $DNS_SERVER_SECONDARY; };
allow-transfer { any; key "backup-key"; trusted; }; allow-transfer { any; key "backup-key"; trusted; };
allow-update {key "certbot."; key "dhcp-key"; trusted; }; allow-update {key "certbot."; key "dhcp-key"; trusted; };
file "$VAR_DIR/zones/$file_name"; file "$VAR_DIR/primary/$file_name";
}; };
# ********** end $domain_name ********** # ********** end $domain_name **********