Support of ignoring hostnames conatining -alt or -neu.
This commit is contained in:
parent
9b1825c714
commit
8a00a00ace
@ -364,18 +364,20 @@ echo -e "\033[32m--\033[m"
|
||||
echo ""
|
||||
echo "Ignore Hostnames containing \"-alt\" (as ww-alt.oopen.de or d-alt.mx.oopen.de)"
|
||||
echo ""
|
||||
echo " Type 'return' for the yellow highlighted one.."
|
||||
echo ""
|
||||
OK=
|
||||
IGNORE_ALT_HOSTNAMES=false
|
||||
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
|
||||
echononl "Ignore Hostnames containing \"-alt\"? [yes/no]: "
|
||||
echononl "Ignore Hostnames containing \"-alt\"? [\033[33m\033[1myes\033[m/no]: "
|
||||
read OK
|
||||
## - To lower case
|
||||
OK=${OK,,}
|
||||
if [ "X$OK" = "X" ]; then
|
||||
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||
OK=""
|
||||
continue
|
||||
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
|
||||
@ -474,25 +476,25 @@ echo ""
|
||||
|
||||
echo ""
|
||||
if $_set_ipv4 ; then
|
||||
echo "Old IPv4 Address..................: $IPv4_ADDRESS_OLD"
|
||||
echo "New IPv4 Address..................: $IPv4_ADDRESS_NEW"
|
||||
echo "Old IPv4 Address...........................: $IPv4_ADDRESS_OLD"
|
||||
echo "New IPv4 Address...........................: $IPv4_ADDRESS_NEW"
|
||||
else
|
||||
echo -e "IPv4 Address(es)..................: \033[33mNone\033[m"
|
||||
echo -e "IPv4 Address(es)...........................: \033[33mNone\033[m"
|
||||
fi
|
||||
echo ""
|
||||
if $_set_ipv6 ; then
|
||||
echo "Old IPv6 Address..................: $IPv6_ADDRESS_OLD"
|
||||
echo "New IPv6 Address..................: $IPv6_ADDRESS_NEW"
|
||||
echo "Old IPv6 Address...........................: $IPv6_ADDRESS_OLD"
|
||||
echo "New IPv6 Address...........................: $IPv6_ADDRESS_NEW"
|
||||
else
|
||||
echo -e "IPv6 Address(es)..................: \033[33mNone\033[m"
|
||||
echo -e "IPv6 Address(es)........................: \033[33mNone\033[m"
|
||||
fi
|
||||
echo ""
|
||||
echo "Ignore hostnames containing \"-alt\".: $IGNORE_ALT_HOSTNAMES"
|
||||
echo "Ignore hostnames containing \"-alt\"/\"-neu\"..: $IGNORE_ALT_HOSTNAMES"
|
||||
echo ""
|
||||
echo "Bind Configuration Directory......: $CONF_FILE_DIR"
|
||||
echo "Zones Declaration File............: $ZONES_DECLARATION_FILE"
|
||||
echo "Zone File Directory (master)......: $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 (master)...............: $ZONE_FILE_MASTER_DIR"
|
||||
#echo "Zone File Suffix...........................: $ZONE_FILE_SUFFIX"
|
||||
|
||||
echo ""
|
||||
OK=
|
||||
@ -623,60 +625,93 @@ for _val in ${zonefiles_arr[@]} ; do
|
||||
echononl "\t Set new IPv4 address ($IPv4_ADDRESS_NEW).."
|
||||
|
||||
_replaced=false
|
||||
_failed=false
|
||||
if grep -e "IN\s*A\s*$IPv4_ADDRESS_OLD" $zone_file > /dev/null 2>&1 ; then
|
||||
perl -i -n -p -e "s#IN\s+A\s+$IPv4_ADDRESS_OLD#IN A $IPv4_ADDRESS_NEW#" $zone_file
|
||||
if [ "$?" = "0" ]; then
|
||||
echo_ok
|
||||
_replaced=true
|
||||
else
|
||||
|
||||
if $IGNORE_ALT_HOSTNAMES ; then
|
||||
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\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
|
||||
perl -i -n -p -e "s#^(.+(-neu).*)\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
|
||||
|
||||
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
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if $_failed ; then
|
||||
echo_failed
|
||||
error "Replacing $IPv4_ADDRESS_OLD with $IPv4_ADDRESS_NEW in zone file \"$zone_file\" failed!"
|
||||
else
|
||||
echo_ok
|
||||
_replaced=true
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
if $_replaced && $IGNORE_ALT_HOSTNAMES ; then
|
||||
echononl "\t Setting back hostnames containing \"-alt\".."
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\s+IN\s+A\s+$IPv4_ADDRESS_NEW#\1 IN A $IPv4_ADDRESS_OLD#" $zone_file > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "Setting back hostnames containing \"-alt\" to $IPv4_ADDRESS_OLD in zone file \"$zone_file\" failed!"
|
||||
fi
|
||||
fi
|
||||
|
||||
## - setze neue ipv6 adresse
|
||||
## -
|
||||
echononl "\t Set new IPv6 address ($IPv6_ADDRESS_NEW).."
|
||||
|
||||
_replaced_ipv6=false
|
||||
_failed=false
|
||||
if grep -e "IN\s*AAAA\s*$IPv6_ADDRESS_OLD" $zone_file > /dev/null 2>&1 ; then
|
||||
|
||||
if $IGNORE_ALT_HOSTNAMES ; then
|
||||
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\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
|
||||
perl -i -n -p -e "s#^(.+(-neu).*)\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 [ "$?" = "0" ]; then
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
if $IGNORE_ALT_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
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if $_failed ; then
|
||||
echo_failed
|
||||
error "Replacing $IPv6_ADDRESS_OLD with $IPv6_ADDRESS_NEW in zone file \"$zone_file\" failed!"
|
||||
else
|
||||
echo_ok
|
||||
_replaced=true
|
||||
_replaced_ipv6=true
|
||||
else
|
||||
echo_failed
|
||||
error "Replacing $IPv6_ADDRESS_OLD with $IPv6_ADDRESS_NEW in zone file \"$zone_file\" failed!"
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
if $_replaced_ipv6 && $IGNORE_ALT_HOSTNAMES ; then
|
||||
echononl "\t Setting back hostnames containing \"-alt\".."
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\s+IN\s+AAAA\s+$IPv6_ADDRESS_NEW#\1 IN AAAA $IPv6_ADDRESS_OLD#" $zone_file > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "Setting back hostnames containing \"-alt\" to $IPv6_ADDRESS_OLD in zone file \"$zone_file\" failed!"
|
||||
fi
|
||||
fi
|
||||
|
||||
# - Calculate new serial
|
||||
# -
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user