#!/bin/zsh
# Version 01.0
# Script to add a new slave zone to /etc/bind/named.conf.local on ns3.dynproxy.net
# Script Name: bind_add_slave_zone_ns3.sh
# Variables
NAMED_CONF="/etc/bind/named.conf.local"
CACHE_DIR="/var/cache/bind"
# Check if a domain name argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <domain.tld>"
exit 1
fi
DOMAIN=$1
ZONE_FILE="$CACHE_DIR/$DOMAIN.db"
# Check if the zone configuration already exists
if grep -q "zone \"$DOMAIN\"" $NAMED_CONF; then
echo "Zone $DOMAIN already exists in $NAMED_CONF. Aborting!"
exit 2
fi
# Append zone configuration to named.conf.local
echo "Adding slave zone configuration for $DOMAIN to $NAMED_CONF"
cat <<EOF >> $NAMED_CONF
zone "$DOMAIN" {
type slave;
file "$ZONE_FILE";
masters { 23.88.113.138; 116.202.112.180; };
allow-transfer { key "ns3-key"; };
};
EOF
# Reload BIND configuration
echo "Reloading BIND configuration"
rndc reload
# Success message
echo "Slave zone for $DOMAIN has been added successfully"