diff --git a/bind_remove_domain_on_slave.sh b/bind_remove_domain_on_slave.sh index e3179c0..03852ad 100755 --- a/bind_remove_domain_on_slave.sh +++ b/bind_remove_domain_on_slave.sh @@ -472,6 +472,7 @@ while IFS='' read -r _line || [[ -n $_line ]] ; do if [[ "$_line" =~ type[[:space:]]+slave ]]; then _is_slave=true fi + if $_is_slave && [[ "$_line" =~ ^[[:space:]]*zone[[:space:]]+\"? ]]; then _found=false _last_line=$((line_number - 1)) @@ -483,6 +484,14 @@ while IFS='' read -r _line || [[ -n $_line ]] ; do done < "$ZONES_DECLARATION_FILE" +# - if zone declaration was the last one in file "$ZONES_DECLARATION_FILE" +# - +if $_found && [[ $_last_line -eq 0 ]]; then + _last_line=$line_number + _found=false +fi + + if $_found ; then fatal "Configuration for zone '${DOMAIN_REQUESTED_TO_REMOVE}' was found, but cannot be deleted." fi