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

@@ -324,6 +324,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>\"? [yes/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"
@@ -425,24 +455,25 @@ echo ""
echo ""
if $_set_ipv4 ; then
echo "IPv4 Address(es)..................: $IPv4_ADDRESS"
echo "IPv4 Address(es)........................: $IPv4_ADDRESS"
else
echo -e "IPv4 Address(es)..................: \033[33mNone\033[m"
echo -e "IPv4 Address(es)........................: \033[33mNone\033[m"
fi
if $_set_ipv6 ; then
echo "IPv6 Address(es)..................: $IPv6_ADDRESS"
echo "IPv6 Address(es)........................: $IPv6_ADDRESS"
else
echo -e "IPv6 Address(es)..................: \033[33mNone\033[m"
echo -e "IPv6 Address(es)........................: \033[33mNone\033[m"
fi
echo ""
echo "New TTL...........................: $TTL"
echo "New TTL.................................: $TTL"
echo ""
echo "Ignore hostnames containing \"-alt\": $IGNORE_ALT_HOSTNAMES"
echo "Ignore hostnames containing \"-alt\"......: $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"
echo "Zone File Directory...............: $ZONE_FILE_MASTER_DIR"
#echo "Zone File Suffix..................: $ZONE_FILE_SUFFIX"
echo "Bind Configuration Directory............: $CONF_FILE_DIR"
echo "Zones Declaration File..................: $ZONES_DECLARATION_FILE"
echo "Zone File Directory.....................: $ZONE_FILE_MASTER_DIR"
#echo "Zone File Suffix........................: $ZONE_FILE_SUFFIX"
echo ""
OK=
@@ -535,6 +566,7 @@ echo -e "\033[37m\033[1mDetermine zone files conatining ip-adressse for which TT
_found=false
_is_master=false
zonefiles_arr=()
zonefiles_not_present_arr=()
zone_file=""
regex_master="type[[:space:]]+master"
regex_file="^[[:space:]]*file"
@@ -566,6 +598,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
@@ -669,6 +711,16 @@ for _val in ${zonefiles_arr[@]} ; do
error "Setting back hostnames containing \"-alt\" for $_ipv4_address in zone file \"$zone_file\" failed!"
fi
fi
if $_replaced && $IGNORE_AUTOCONFIG_HOSTNAMES ; then
echononl "\t Setting back hostnames \"autoconfig.<DOMAIN>\".."
perl -i -n -p -e "s#^(\s*autoconfig\s+)$TTL\s+IN\s+A\s+$_ipv4_address#\1IN A $_ipv4_address#" $zone_file > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Setting back hostnames containing \"-alt\" for $_ipv4_address in zone file \"$zone_file\" failed!"
fi
fi
fi
done
fi
@@ -707,6 +759,16 @@ for _val in ${zonefiles_arr[@]} ; do
error "Setting back hostnames containing \"-alt\" for $_ipv6_address in zone file \"$zone_file\" failed!"
fi
fi
if $_replaced && $IGNORE_AUTOCONFIG_HOSTNAMES ; then
echononl "\t Setting back hostnames \"autoconfig.<DOMAIN>\".."
perl -i -n -p -e "s#^(\s*autoconfig\s+)$TTL\s+IN\s+AAAA\s+$_ipv6_address#\1IN AAAA $_ipv6_address#" $zone_file > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Setting back hostnames containing \"-alt\" for $_ipv6_address in zone file \"$zone_file\" failed!"
fi
fi
fi
done
fi
@@ -771,5 +833,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