bind_change_ttl.sh: fix error handle hostnames ending with two or more nimbers like 'web-01'.
This commit is contained in:
parent
c2690d85a5
commit
9b1825c714
@ -643,7 +643,10 @@ for _val in ${zonefiles_arr[@]} ; do
|
||||
if $(grep -q -E "\s+$TTL\s+IN\s+As+$_ipv4_address" $zone_file 2> /dev/null) ; then
|
||||
echo_skipped
|
||||
else
|
||||
perl -i -n -p -e "s#([0-9]{2,5}\s+)?IN\s+A\s+$_ipv4_address#$TTL IN A $_ipv4_address#" $zone_file > /dev/null 2>&1
|
||||
# Note:
|
||||
# '\1${TTL}' in replace string DOES NOT work in perl regex.
|
||||
#
|
||||
sed -i -r -e"s#(\s+)([0-9]{2,5}\s+)?IN\s+A\s+$_ipv4_address#\1${TTL} IN A $_ipv4_address#" $zone_file > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
echo_ok
|
||||
_replaced=true
|
||||
@ -655,7 +658,7 @@ for _val in ${zonefiles_arr[@]} ; do
|
||||
|
||||
if $_replaced && $IGNORE_ALT_HOSTNAMES ; then
|
||||
echononl "\t Setting back hostnames containing \"-alt\".."
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\s+$TTL\s+IN\s+A\s+$_ipv4_address#\1 IN A $_ipv4_address#" $zone_file > /dev/null 2>&1
|
||||
perl -i -n -p -e "s#^(.+(-alt)\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
|
||||
@ -679,7 +682,10 @@ for _val in ${zonefiles_arr[@]} ; do
|
||||
if $(grep -q -E "\s+$TTL\s+IN\s+AAAA\s+$_ipv6_address" $zone_file 2> /dev/null) ; then
|
||||
echo_skipped
|
||||
else
|
||||
perl -i -n -p -e "s#([0-9]{2,5}\s+)?IN\s+AAAA\s+$_ipv6_address#$TTL IN AAAA $_ipv6_address#" $zone_file > /dev/null 2>&1
|
||||
# Note:
|
||||
# '\1${TTL}' in replace string DOES NOT work in perl regex.
|
||||
#
|
||||
sed -i -r -e"s#(\s+)([0-9]{2,5}\s+)?IN\s+AAAA\s+$_ipv6_address#\1${TTL} IN AAAA $_ipv6_address#" $zone_file > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
echo_ok
|
||||
_replaced=true
|
||||
@ -690,7 +696,7 @@ for _val in ${zonefiles_arr[@]} ; do
|
||||
fi
|
||||
if $_replaced && $IGNORE_ALT_HOSTNAMES ; then
|
||||
echononl "\t Setting back hostnames containing \"-alt\".."
|
||||
perl -i -n -p -e "s#^(.+(-alt).*)\s+$TTL\s+IN\s+AAAA\s+$_ipv6_address#\1 IN AAAA $_ipv6_address#" $zone_file > /dev/null 2>&1
|
||||
perl -i -n -p -e "s#^(.+(-alt)\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
|
||||
|
Loading…
Reference in New Issue
Block a user