#!/bin/zsh # Version 01.0 # Script to add a new slave zone to /etc/bind/named.conf.local on ns2.dynproxy.net # Script Name: bind_add_slave_zone.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 " exit 1 fi DOMAIN=$1 ZONE_FILE="$CACHE_DIR/db.$DOMAIN" # 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 <> $NAMED_CONF zone "$DOMAIN" { type slave; file "$ZONE_FILE"; masters { 23.88.113.138; }; 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"