Add scripts bind_change_ip.sh'' and 'bind_change_ip.sh'.

This commit is contained in:
2023-12-25 00:30:04 +01:00
parent 1b333791b3
commit f91c31b250
5 changed files with 1945 additions and 14 deletions

View File

@@ -393,6 +393,36 @@ done
[[ $OK = "yes" ]] && IGNORE_ALT_HOSTNAMES=true
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Ignore Hostnames \"autoconfig\" (as autoconfig.oopen.de)"
echo ""
echo " Type 'return' for the yellow highlighted one.."
echo ""
OK=
IGNORE_AUTOCONFIG_HOSTNAMES=false
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
echononl "Ignore Hostnames \"autoconfig.<domain>\"? [\033[33m\033[1myes\033[m/no]: "
read OK
## - To lower case
OK=${OK,,}
if [ "X$OK" = "X" ]; then
OK='yes'
#echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
#OK=""
#continue
fi
if [ "$OK" = "yes" -o "$OK" = "no" ] ; then
break
else
OK=""
fi
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n"
done
[[ $OK = "yes" ]] && IGNORE_AUTOCONFIG_HOSTNAMES=true
echo ""
echo ""
echo -e "\033[32m--\033[m"
@@ -494,6 +524,7 @@ else
fi
echo ""
echo "Ignore hostnames containing \"-alt\"/\"-neu\"..: $IGNORE_ALT_HOSTNAMES"
echo "Ignore hostnames \"autoconfig.<domain>\".....: $IGNORE_AUTOCONFIG_HOSTNAMES"
echo ""
echo "Bind Configuration Directory...............: $CONF_FILE_DIR"
echo "Zones Declaration File.....................: $ZONES_DECLARATION_FILE"
@@ -538,6 +569,7 @@ echo -e "\033[37m\033[1mDetermine zone files conatining ip-adressse requested fo
_found=false
_is_master=false
zonefiles_arr=()
zonefiles_not_present_arr=()
zone_file=""
regex_master="type[[:space:]]+master"
regex_file="^[[:space:]]*file"
@@ -569,6 +601,16 @@ while IFS='' read -r _line || [[ -n $_line ]] ; do
fi
shopt -u extglob
fi
if [[ -n "${zone_file}" ]] ; then
if [[ ! -f "${zone_file}" ]] ; then
if ! containsElement "${zone_file}" "${zonefiles_not_present_arr[@]}" ; then
zonefiles_not_present_arr+=("${zone_file}")
fi
continue
fi
fi
if [[ $_line =~ $regex_master ]]; then
_is_master=true
fi
@@ -611,8 +653,6 @@ done < "$ZONES_DECLARATION_FILE"
echo ""
for _val in ${zonefiles_arr[@]} ; do
IFS=':' read -a _val_arr <<< "${_val}"
@@ -620,6 +660,11 @@ for _val in ${zonefiles_arr[@]} ; do
zone_file="${_val_arr[0]}"
zone="${_val_arr[1]}"
if [[ ! -f "${zone_file}" ]]; then
warn "Zonefile \033[1m$zone_file\033[m no fount!"
continue
fi
echo -e "\tEditing \033[1m$zone_file\033[m .."
_replaced=false
@@ -644,12 +689,20 @@ for _val in ${zonefiles_arr[@]} ; do
fi
fi
if $IGNORE_AUTOCONFIG_HOSTNAMES ; then
perl -i -n -p -e "s#^\s*(autoconfig.*)\s+IN\s+A\s+$IPv4_ADDRESS_OLD#\1 IN A 888.888.888.888#" $zone_file > /dev/null 2>&1
if [[ $? -gt 0 ]]; then
_failed=true
fi
fi
perl -i -n -p -e "s#IN\s+A\s+$IPv4_ADDRESS_OLD#IN A $IPv4_ADDRESS_NEW#" $zone_file > /dev/null 2>&1
if [[ $? -gt 0 ]]; then
_failed=true
fi
if $IGNORE_ALT_HOSTNAMES ; then
if $IGNORE_ALT_HOSTNAMES || $IGNORE_AUTOCONFIG_HOSTNAMES ; then
perl -i -n -p -e "s#IN\s+A\s+888.888.888.888#IN A $IPv4_ADDRESS_OLD#" $zone_file > /dev/null 2>&1
if [[ $? -gt 0 ]]; then
@@ -690,12 +743,19 @@ for _val in ${zonefiles_arr[@]} ; do
fi
fi
if $IGNORE_AUTOCONFIG_HOSTNAMES ; then
perl -i -n -p -e "s#^\s*(autoconfig.*)\s+IN\s+AAAA\s+$IPv6_ADDRESS_OLD#\1 IN AAAA 88:88:88::88#" $zone_file > /dev/null 2>&1
if [[ $? -gt 0 ]]; then
_failed=true
fi
fi
perl -i -n -p -e "s#IN\s+AAAA\s+$IPv6_ADDRESS_OLD#IN AAAA $IPv6_ADDRESS_NEW#" $zone_file
if [[ $? -gt 0 ]]; then
_failed=true
fi
if $IGNORE_ALT_HOSTNAMES ; then
if $IGNORE_ALT_HOSTNAMES || $IGNORE_AUTOCONFIG_HOSTNAMES ; then
perl -i -n -p -e "s#IN\s+AAAA\s+88:88:88::88#IN AAAA $IPv6_ADDRESS_OLD#" $zone_file > /dev/null 2>&1
if [[ $? -gt 0 ]]; then
@@ -777,6 +837,14 @@ if [[ -d "${ZONE_FILE_MASTER_DIR}.${backup_date}" ]] ; then
fi
fi
if [[ ${#zonefiles_not_present_arr[@]} -gt 0 ]] ; then
echo ""
warn "The following zonefiles were not found!"
for _val in ${zonefiles_not_present_arr[@]} ; do
echo -e "\t $_val"
done
fi
echo ""
clean_up 0