Subversion Repositories My Stuff

Compare Revisions

Ignore whitespace Rev 18 → Rev 19

/trunk/Bash/bind_zone_config.sh
0,0 → 1,93
#!/bin/sh
 
#####################################################################
# Script to generate bind configuration for many domains for
# one server
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Author: Andrzej Kardaƛ
# License: GPLv3
# The full version of the licencse can be obtainted by visiting:
# http://www.gnu.org/licenses/gpl.html
#######################################################################
BIND_DIR=/chroot/dns/var/bind/
MASTER_CONF_FILE=${BIND_DIR}conf/master.conf
SLAVE_CONF_FILE=${BIND_DIR}conf/slave.conf
SLAVE_DIR=slave
MASTER_DIR=master
SERIAL=$(date +"%Y%m%y")01
MASTER_SERVER_IP="X.X.X.X"
SLAVE_SERVERS_NAMES="nameserver1 nameserver2"
HOSTNAME=short_server_name
CNAMES="www"
MX=
MX_IP=X.X.X.X
FILE=${2}
 
#Checking the list of parameters
 
if ( [ $# -lt 2 ] ) then
 
echo "To few arguments were passed to script"
echo "Usage ./bind_config.sh type zone_list_file"
echo "Type can be master | slave"
 
exit 0
fi
 
#Creating the zone files
 
if [ "${1}" = "master" ]; then
 
while read line
do
echo "zone \"$line\" IN { type master; file \"${MASTER_DIR}/$line\"; };" >> ${MASTER_CONF_FILE}
echo "" > ${BIND_DIR}${MASTER_DIR}/$line
echo "\$TTL 600" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "; $line" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "@ IN SOA ${HOSTNAME}.$line. hostmaster.$line. (" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " ${SERIAL} ; serial" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " 12h ; refresh" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " 1h ; retry" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " 2w ; expire" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " 1h ; minimum" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " )" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "" >> ${BIND_DIR}${MASTER_DIR}/$line
echo " IN NS ${HOSTNAME}.$line." >> ${BIND_DIR}${MASTER_DIR}/$line
for server in ${SLAVE_SERVERS_NAMES}
do
echo " IN NS $server." >> ${BIND_DIR}${MASTER_DIR}/$line
done
if [ ${MX} ]; then
echo " IN MX 10 ${MX}.$line." >> ${BIND_DIR}${MASTER_DIR}/$line
fi
echo "@ IN A ${MASTER_SERVER_IP}" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "; host_records" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "localhost IN A 127.0.0.1" >> ${BIND_DIR}${MASTER_DIR}/$line
echo "${HOSTNAME} IN A ${MASTER_SERVER_IP}" >> ${BIND_DIR}${MASTER_DIR}/$line
if [ ${MX} ]; then
echo "${MX} IN A ${MASTER_SERVER_IP}" >> ${BIND_DIR}${MASTER_DIR}/$line
fi
for cname in ${CNAMES}
do
echo "${cname} IN CNAME ${HOSTNAME}" >> ${BIND_DIR}${MASTER_DIR}/$line
done
done < ${FILE}
 
elif [ "${1}" = "slave" ]; then
 
while read line
do
echo "zone \"$line\" IN { type slave; masters{ ${MASTER_SERVER_IP}; }; file \"${SLAVE_DIR}/$line\"; };" >> ${SLAVE_CONF_FILE}
done < ${FILE}
 
else
 
echo "Usage ./bind_zone_config.sh type zone_list_file"
echo "Type can be master | slave"
exit 0
fi
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property