- Integrate configuration file to script bind_change_ip.sh.
- Read Zonefiles from bind configuration instead from given zone file directory.
This commit is contained in:
parent
2124a5bbff
commit
bbb8c5a023
@ -1,20 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
## --- Variables (default Values)
|
working_dir="$(dirname $(realpath $0))"
|
||||||
## ---
|
conf_file="${working_dir}/conf/bind.conf"
|
||||||
_zone_file_dir=/etc/bind/master
|
|
||||||
#_zone_file_dir=/root/tmp/master
|
log_file="$(mktemp)"
|
||||||
|
|
||||||
|
backup_date="$(date +%Y-%m-%d-%H%M)"
|
||||||
|
|
||||||
_serial_new=`date +%Y%m%d01`
|
_serial_new=`date +%Y%m%d01`
|
||||||
|
|
||||||
_zone_file_suffix=zone
|
|
||||||
## ---
|
|
||||||
## --- End: Variables (default Values)
|
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
#-----------------------------
|
||||||
|
# Base Function(s)
|
||||||
|
#-----------------------------
|
||||||
|
#---------------------------------------
|
||||||
|
|
||||||
|
clean_up() {
|
||||||
|
|
||||||
|
# Perform program exit housekeeping
|
||||||
|
rm $log_file
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
## --- some functions
|
|
||||||
## ---
|
|
||||||
echononl(){
|
echononl(){
|
||||||
echo X\\c > /tmp/shprompt$$
|
echo X\\c > /tmp/shprompt$$
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
@ -31,7 +40,7 @@ fatal(){
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "\t\033[31m\033[1mScript is canceled\033[m\033[m"
|
echo -e "\t\033[31m\033[1mScript is canceled\033[m\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
exit 1
|
clean_up 1
|
||||||
}
|
}
|
||||||
|
|
||||||
warn (){
|
warn (){
|
||||||
@ -110,8 +119,73 @@ is_valid_ipv6() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## ---
|
trap clean_up SIGHUP SIGINT SIGTERM
|
||||||
## --- END: functions
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
#-----------------------------
|
||||||
|
# Setting Defaults
|
||||||
|
#-----------------------------
|
||||||
|
#---------------------------------------
|
||||||
|
|
||||||
|
DEFAULT_CONF_FILE_DIR="/etc/bind"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
#-----------------------------
|
||||||
|
# Load default values from bind.conf
|
||||||
|
#
|
||||||
|
# Overwrites the settings above
|
||||||
|
#
|
||||||
|
#-----------------------------
|
||||||
|
#---------------------------------------
|
||||||
|
|
||||||
|
#clear
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echononl " Loading default Configuration values from $(basename ${conf_file}).."
|
||||||
|
if [[ ! -f "$conf_file" ]]; then
|
||||||
|
echo_skipped
|
||||||
|
else
|
||||||
|
source "${conf_file}" > $log_file 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fatal "$(cat $log_file)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$CONF_FILE_DIR" ]] && DEFAULT_CONF_FILE_DIR="$CONF_FILE_DIR"
|
||||||
|
|
||||||
|
if [[ -n "$ZONE_FILE_MASTER_DIR" ]] ; then
|
||||||
|
DEFAULT_ZONE_FILE_MASTER_DIR="$ZONE_FILE_MASTER_DIR"
|
||||||
|
else
|
||||||
|
DEFAULT_ZONE_FILE_MASTER_DIR="${DEFAULT_CONF_FILE_DIR}/master"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ZONE_FILE_SLAVE_DIR" ]] ; then
|
||||||
|
DEFAULT_ZONE_FILE_SLAVE_DIR="$ZONE_FILE_SLAVE_DIR"
|
||||||
|
else
|
||||||
|
DEFAULT_ZONE_FILE_SLAVE_DIR="${DEFAULT_CONF_FILE_DIR}/slave"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ZONE_FILE_SUFFIX" ]] ; then
|
||||||
|
DEFAULT_ZONE_FILE_SUFFIX="$ZONE_FILE_SUFFIX"
|
||||||
|
else
|
||||||
|
DEFAULT_ZONE_FILE_SUFFIX='zone'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ZONES_DECLARATION_FILE" ]] ; then
|
||||||
|
DEFAULT_ZONES_DECLARATION_FILE="$ZONES_DECLARATION_FILE"
|
||||||
|
else
|
||||||
|
DEFAULT_ZONES_DECLARATION_FILE="${CONF_FILE_DIR}/named.conf.local"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
@ -132,7 +206,7 @@ while [ "X$IPv4_ADDRESS_OLD" = "X" ]; do
|
|||||||
IPv4_ADDRESS_OLD=""
|
IPv4_ADDRESS_OLD=""
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$IPv4_ADDRESS_OLD" = "none" ];then
|
if [ "${IPv4_ADDRESS_OLD,,}" = "none" ];then
|
||||||
_set_ipv4=false
|
_set_ipv4=false
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -203,7 +277,7 @@ echo -e "\033[32m--\033[m"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Insert IPv6-Address which do you want to change (old address)."
|
echo "Insert IPv6-Address which do you want to change (old address)."
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Type \"\033[33mNone\033[m\" if no IPv6 address should be changed."
|
echo -e "Type \"\033[33mnone\033[m\" if no IPv6 address should be changed."
|
||||||
echo ""
|
echo ""
|
||||||
IPv6_ADDRESS_OLD=
|
IPv6_ADDRESS_OLD=
|
||||||
_set_ipv6=true
|
_set_ipv6=true
|
||||||
@ -217,14 +291,13 @@ while [ "X$IPv6_ADDRESS_OLD" = "X" ]; do
|
|||||||
IPv6_ADDRESS_OLD=""
|
IPv6_ADDRESS_OLD=""
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$IPv6_ADDRESS_OLD" = "none" ];then
|
if [ "${IPv6_ADDRESS_OLD,,}" = "none" ];then
|
||||||
_set_ipv6=false
|
_set_ipv6=false
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ipv6_addresses_old_arr=()
|
ipv6_addresses_old_arr=()
|
||||||
for _ipv6_address in $IPv6_ADDRESS_OLD ; do
|
for _ipv6_address in $IPv6_ADDRESS_OLD ; do
|
||||||
echo "$_ipv6_address"
|
|
||||||
containsElement "$_ipv6_address" "${ipv6_addresses_old_arr[@]}" && continue
|
containsElement "$_ipv6_address" "${ipv6_addresses_old_arr[@]}" && continue
|
||||||
ipv6_addresses_old_arr+=("$_ipv6_address")
|
ipv6_addresses_old_arr+=("$_ipv6_address")
|
||||||
done
|
done
|
||||||
@ -289,37 +362,51 @@ if ! $_set_ipv6 && ! $_set_ipv4 ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
#echo ""
|
||||||
echo -e "\033[32m--\033[m"
|
#echo -e "\033[32m--\033[m"
|
||||||
echo ""
|
#echo ""
|
||||||
echo "Insert the directory, where your zone-files resides."
|
#echo "Insert the directory, where your zone-files resides."
|
||||||
echo ""
|
#echo ""
|
||||||
echo ""
|
#echo ""
|
||||||
ZONE_FILE_DIR=
|
#ZONE_FILE_MASTER_DIR=""
|
||||||
while [ "X$ZONE_FILE_DIR" = "X" ]; do
|
#if [[ -n "$DEFAULT_ZONE_FILE_MASTER_DIR" ]] ; then
|
||||||
echononl "Zone File Directory [$_zone_file_dir]: "
|
# echononl "Zone File Directory (master) [${DEFAULT_ZONE_FILE_MASTER_DIR}]: "
|
||||||
read ZONE_FILE_DIR
|
# read ZONE_FILE_MASTER_DIR
|
||||||
if [ "X$ZONE_FILE_DIR" = "X" ]; then
|
# if [[ "X$ZONE_FILE_MASTER_DIR" = "X" ]]; then
|
||||||
ZONE_FILE_DIR=$_zone_file_dir
|
# ZONE_FILE_MASTER_DIR="$DEFAULT_ZONE_FILE_MASTER_DIR"
|
||||||
fi
|
# fi
|
||||||
if [ ! -d $ZONE_FILE_DIR ]; then
|
#else
|
||||||
echo -e "\n\tDirectory \033[33m\033[1m$ZONE_FILE_DIR\033[m does NOT exist!\n"
|
# echononl "Zone File Directory (master): "
|
||||||
ZONE_FILE_DIR=
|
# read ZONE_FILE_MASTER_DIR
|
||||||
fi
|
# while [ "X$ZONE_FILE_MASTER_DIR" = "X" ] ; do
|
||||||
done
|
# echo -e "\n\t\033[33m\033[1mSetting 'Zone File Directory (master)' is required!\033[m\n"
|
||||||
|
# echononl "Zone File Directory (master): "
|
||||||
echo ""
|
# read ZONE_FILE_MASTER_DIR
|
||||||
echo -e "\033[32m--\033[m"
|
# done
|
||||||
echo ""
|
#fi
|
||||||
echo "Insert the file-suffix of thr zone-files"
|
#
|
||||||
echo ""
|
#echo ""
|
||||||
echo ""
|
#echo -e "\033[32m--\033[m"
|
||||||
ZONE_FILE_SUFFIX=
|
#echo ""
|
||||||
echononl "Suffix of Zone Files [$_zone_file_suffix]: "
|
#echo "Insert the file-suffix of the zone-files"
|
||||||
read ZONE_FILE_SUFFIX
|
#echo ""
|
||||||
if [ "X$ZONE_FILE_SUFFIX" = "X" ]; then
|
#echo ""
|
||||||
ZONE_FILE_SUFFIX=$_zone_file_suffix
|
#ZONE_FILE_SUFFIX=
|
||||||
fi
|
#if [[ -n "$DEFAULT_ZONE_FILE_SUFFIX" ]] ; then
|
||||||
|
# echononl "Suffix of Zone Files [${DEFAULT_ZONE_FILE_SUFFIX}]: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# if [[ "X$ZONE_FILE_SUFFIX" = "X" ]]; then
|
||||||
|
# ZONE_FILE_SUFFIX="$DEFAULT_ZONE_FILE_SUFFIX"
|
||||||
|
# fi
|
||||||
|
#else
|
||||||
|
# echononl "Suffix of Zone Files: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# while [ "X$ZONE_FILE_SUFFIX" = "X" ] ; do
|
||||||
|
# echo -e "\n\t\033[33m\033[1mSetting 'Suffix of Zone Files' is required!\033[m\n"
|
||||||
|
# echononl "Suffix of Zone Files: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# done
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@ -350,6 +437,109 @@ done
|
|||||||
[[ $OK = "yes" ]] && IGNORE_ALT_HOSTNAMES=true
|
[[ $OK = "yes" ]] && IGNORE_ALT_HOSTNAMES=true
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo "Common parameters"
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Insert directory containing the bind configuration files."
|
||||||
|
echo ""
|
||||||
|
CONF_FILE_DIR=""
|
||||||
|
if [[ -n "$DEFAULT_CONF_FILE_DIR" ]] ; then
|
||||||
|
echononl "Bind Configuration Directory [${DEFAULT_CONF_FILE_DIR}]: "
|
||||||
|
read CONF_FILE_DIR
|
||||||
|
if [[ "X$CONF_FILE_DIR" = "X" ]]; then
|
||||||
|
CONF_FILE_DIR="$DEFAULT_CONF_FILE_DIR"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echononl "Bind Configuration Directory: "
|
||||||
|
read CONF_FILE_DIR
|
||||||
|
while [ "X$CONF_FILE_DIR" = "X" ] ; do
|
||||||
|
echo -e "\n\t\033[33m\033[1mSetting 'Bind Configuration Directory' is required!\033[m\n"
|
||||||
|
echononl "Bind Configuration Directory: "
|
||||||
|
read CONF_FILE_DIR
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$ZONES_DECLARATION_FILE" ]] || DEFAULT_ZONES_DECLARATION_FILE="${CONF_FILE_DIR}/named.conf.local"
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Insert zones declaration file."
|
||||||
|
echo ""
|
||||||
|
ZONES_DECLARATION_FILE=""
|
||||||
|
if [[ -n "$DEFAULT_ZONES_DECLARATION_FILE" ]] ; then
|
||||||
|
echononl "Zones Declaration File [${DEFAULT_ZONES_DECLARATION_FILE}]: "
|
||||||
|
read ZONES_DECLARATION_FILE
|
||||||
|
if [[ "X$ZONES_DECLARATION_FILE" = "X" ]]; then
|
||||||
|
ZONES_DECLARATION_FILE="$DEFAULT_ZONES_DECLARATION_FILE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echononl "Zones Declaration File: "
|
||||||
|
read ZONES_DECLARATION_FILE
|
||||||
|
while [ "X$ZONES_DECLARATION_FILE" = "X" ] ; do
|
||||||
|
echo -e "\n\t\033[33m\033[1mSetting 'Zones Declaration File' is required!\033[m\n"
|
||||||
|
echononl "Zones Declaration File: "
|
||||||
|
read ZONES_DECLARATION_FILE
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Insert the directory, where your zone-files resides."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
ZONE_FILE_MASTER_DIR=""
|
||||||
|
if [[ -n "$DEFAULT_ZONE_FILE_MASTER_DIR" ]] ; then
|
||||||
|
echononl "Zone File Directory (master) [${DEFAULT_ZONE_FILE_MASTER_DIR}]: "
|
||||||
|
read ZONE_FILE_MASTER_DIR
|
||||||
|
if [[ "X$ZONE_FILE_MASTER_DIR" = "X" ]]; then
|
||||||
|
ZONE_FILE_MASTER_DIR="$DEFAULT_ZONE_FILE_MASTER_DIR"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echononl "Zone File Directory (master): "
|
||||||
|
read ZONE_FILE_MASTER_DIR
|
||||||
|
while [ "X$ZONE_FILE_MASTER_DIR" = "X" ] ; do
|
||||||
|
echo -e "\n\t\033[33m\033[1mSetting 'Zone File Directory (master)' is required!\033[m\n"
|
||||||
|
echononl "Zone File Directory (master): "
|
||||||
|
read ZONE_FILE_MASTER_DIR
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
#echo ""
|
||||||
|
#echo -e "\033[32m--\033[m"
|
||||||
|
#
|
||||||
|
#echo ""
|
||||||
|
#echo "Insert the file-suffix of the zone-files"
|
||||||
|
#echo ""
|
||||||
|
#echo ""
|
||||||
|
#ZONE_FILE_SUFFIX=
|
||||||
|
#if [[ -n "$DEFAULT_ZONE_FILE_SUFFIX" ]] ; then
|
||||||
|
# echononl "Suffix of Zone Files [${DEFAULT_ZONE_FILE_SUFFIX}]: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# if [[ "X$ZONE_FILE_SUFFIX" = "X" ]]; then
|
||||||
|
# ZONE_FILE_SUFFIX="$DEFAULT_ZONE_FILE_SUFFIX"
|
||||||
|
# fi
|
||||||
|
#else
|
||||||
|
# echononl "Suffix of Zone Files: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# while [ "X$ZONE_FILE_SUFFIX" = "X" ] ; do
|
||||||
|
# echo -e "\n\t\033[33m\033[1mSetting 'Suffix of Zone Files' is required!\033[m\n"
|
||||||
|
# echononl "Suffix of Zone Files: "
|
||||||
|
# read ZONE_FILE_SUFFIX
|
||||||
|
# done
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
@ -373,8 +563,10 @@ fi
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Ignore hostnames containing \"-alt\".: $IGNORE_ALT_HOSTNAMES"
|
echo "Ignore hostnames containing \"-alt\".: $IGNORE_ALT_HOSTNAMES"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Zone File Directory...............: $ZONE_FILE_DIR"
|
echo "Bind Configuration Directory......: $CONF_FILE_DIR"
|
||||||
echo "Zone File Suffix..................: $ZONE_FILE_SUFFIX"
|
echo "Zones Declaration File............: $ZONES_DECLARATION_FILE"
|
||||||
|
echo "Zone File Directory (master)......: $ZONE_FILE_MASTER_DIR"
|
||||||
|
#echo "Zone File Suffix..................: $ZONE_FILE_SUFFIX"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
OK=
|
OK=
|
||||||
@ -398,38 +590,130 @@ done
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
cp -a $ZONE_FILE_DIR ${ZONE_FILE_DIR}.BAK-`date +%Y-%m-%d-%H%M`
|
echononl "\tBackup directory '${ZONE_FILE_MASTER_DIR}'.."
|
||||||
|
cp -a "${ZONE_FILE_MASTER_DIR}" "${ZONE_FILE_MASTER_DIR}.${backup_date}" > $log_file 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fatal "$(cat $log_file)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#if $_set_ipv4 ; then
|
||||||
|
# _zone_files_ipv4=`grep -l -e "$IPv4_ADDRESS_OLD" ${ZONE_FILE_MASTER_DIR}/*.$ZONE_FILE_SUFFIX`
|
||||||
|
# if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
||||||
|
# for _zone_file in $_zone_files_ipv4 ; do
|
||||||
|
# zonefiles_arr+=("$_zone_file")
|
||||||
|
# done
|
||||||
|
# else
|
||||||
|
# for _zone_file in $_zone_files_ipv4 ; do
|
||||||
|
# containsElement "$_zone_file" "${zonefiles_arr[@]}" && continue
|
||||||
|
# zonefiles_arr+=("$_zone_file")
|
||||||
|
# done
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#if $_set_ipv6 ; then
|
||||||
|
# _zone_files_ipv6=`grep -l -e "$_ipv6_address" ${ZONE_FILE_MASTER_DIR}/*.$ZONE_FILE_SUFFIX`
|
||||||
|
# if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
||||||
|
# for _zone_file in $_zone_files_ipv6 ; do
|
||||||
|
# zonefiles_arr+=("$_zone_file")
|
||||||
|
# done
|
||||||
|
# else
|
||||||
|
# for _zone_file in $_zone_files_ipv6 ; do
|
||||||
|
# containsElement "$_zone_file" "${zonefiles_arr[@]}" && continue
|
||||||
|
# zonefiles_arr+=("$_zone_file")
|
||||||
|
# done
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[37m\033[1mDetermine zone files conatining ip-adressse requested for change..\033[m"
|
||||||
|
|
||||||
|
_found=false
|
||||||
|
_is_master=false
|
||||||
zonefiles_arr=()
|
zonefiles_arr=()
|
||||||
if $_set_ipv4 ; then
|
zone_file=""
|
||||||
_zone_files_ipv4=`grep -l -e "$IPv4_ADDRESS_OLD" ${ZONE_FILE_DIR}/*.$ZONE_FILE_SUFFIX`
|
regex_master="type[[:space:]]+master"
|
||||||
if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
regex_file="^[[:space:]]*file"
|
||||||
for _zone_file in $_zone_files_ipv4 ; do
|
while IFS='' read -r _line || [[ -n $_line ]] ; do
|
||||||
zonefiles_arr+=("$_zone_file")
|
|
||||||
done
|
if [[ $_line =~ ^[[:space:]]*zone[[:space:]]+ ]]; then
|
||||||
else
|
_found=true
|
||||||
for _zone_file in $_zone_files_ipv4 ; do
|
#zone="$(echo $_line | awk '{print$2}')"
|
||||||
containsElement "$_zone_file" "${zonefiles_arr[@]}" && continue
|
#shopt -s extglob
|
||||||
zonefiles_arr+=("$_zone_file")
|
#if [[ $zone =~ \; ]]; then
|
||||||
done
|
# zone=${zone%%*(\;)}
|
||||||
|
#fi
|
||||||
|
#if [[ $zone =~ ^\" ]]; then
|
||||||
|
# zone=${zone##*(\")}
|
||||||
|
# zone=${zone%%*(\")}
|
||||||
|
#fi
|
||||||
|
#shopt -u extglob
|
||||||
fi
|
fi
|
||||||
fi
|
if $_found ; then
|
||||||
|
if [[ $_line =~ $regex_file ]]; then
|
||||||
|
zone_file=$(echo $_line | awk '{print$2}')
|
||||||
|
shopt -s extglob
|
||||||
|
if [[ $zone_file =~ \; ]]; then
|
||||||
|
zone_file=${zone_file%%*(\;)}
|
||||||
|
fi
|
||||||
|
if [[ $zone_file =~ ^\" ]]; then
|
||||||
|
zone_file=${zone_file##*(\")}
|
||||||
|
zone_file=${zone_file%%*(\")}
|
||||||
|
fi
|
||||||
|
shopt -u extglob
|
||||||
|
fi
|
||||||
|
if [[ $_line =~ $regex_master ]]; then
|
||||||
|
_is_master=true
|
||||||
|
fi
|
||||||
|
if [[ "$_line" =~ ^[[:space:]]*\}[[:space:]]*\; ]]; then
|
||||||
|
if $_is_master && [[ -n "$zone_file" ]]; then
|
||||||
|
|
||||||
|
|
||||||
if $_set_ipv6 ; then
|
if $_set_ipv4 ; then
|
||||||
_zone_files_ipv6=`grep -l -e "$_ipv6_address" ${ZONE_FILE_DIR}/*.$ZONE_FILE_SUFFIX`
|
|
||||||
|
if $(grep -q -e "$IPv4_ADDRESS_OLD" "$zone_file") ; then
|
||||||
if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
||||||
for _zone_file in $_zone_files_ipv6 ; do
|
zonefiles_arr+=("$zone_file")
|
||||||
zonefiles_arr+=("$_zone_file")
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
for _zone_file in $_zone_files_ipv6 ; do
|
if ! containsElement "$zone_file" "${zonefiles_arr[@]}" ; then
|
||||||
containsElement "$_zone_file" "${zonefiles_arr[@]}" && continue
|
zonefiles_arr+=("$zone_file")
|
||||||
zonefiles_arr+=("$_zone_file")
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if $_set_ipv6 ; then
|
||||||
|
if $(grep -q -e "$IPv6_ADDRESS_OLD" "$zone_file") ; then
|
||||||
|
if [ ${#zonefiles_arr[@]} -eq 0 ] ; then
|
||||||
|
zonefiles_arr+=("$zone_file")
|
||||||
|
else
|
||||||
|
if ! containsElement "$zone_file" "${zonefiles_arr[@]}" ; then
|
||||||
|
zonefiles_arr+=("$zone_file")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
_is_master=false
|
||||||
|
_found=false
|
||||||
|
zone_file=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$ZONES_DECLARATION_FILE"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for zone_file in ${zonefiles_arr[@]} ; do
|
for zone_file in ${zonefiles_arr[@]} ; do
|
||||||
@ -523,5 +807,20 @@ for zone_file in ${zonefiles_arr[@]} ; do
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -d "${ZONE_FILE_MASTER_DIR}.${backup_date}" ]] ; then
|
||||||
|
diff -Nur "${ZONE_FILE_MASTER_DIR}" "${ZONE_FILE_MASTER_DIR}.${backup_date}" > /dev/null 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
info "No zone file has changed.\n\t Removing previously created backup"
|
||||||
|
echononl "\tDelete '${ZONE_FILE_MASTER_DIR}.${backup_date}'.."
|
||||||
|
rm -rf "${ZONE_FILE_MASTER_DIR}.${backup_date}" > $log_file 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
clean_up 0
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
#ZONE_FILE_SLAVE_DIR="${CONF_FILE_DIR}/slave"
|
#ZONE_FILE_SLAVE_DIR="${CONF_FILE_DIR}/slave"
|
||||||
|
|
||||||
|
|
||||||
|
# - ZONE_FILE_SUFFIX
|
||||||
|
# -
|
||||||
|
# - Defaults to 'zone'
|
||||||
|
# -
|
||||||
|
#ZONE_FILE_SUFFIX="zone"
|
||||||
|
|
||||||
|
|
||||||
# - ZONES_DECLARATION_FILE
|
# - ZONES_DECLARATION_FILE
|
||||||
# -
|
# -
|
||||||
# - File containing zone declarations
|
# - File containing zone declarations
|
||||||
|
Loading…
Reference in New Issue
Block a user