This is part of the script for setting the hostname. Suppose the situation that the user, setting the host name in response to the request, re-registers in his name "localdomain". Now the script completes successfully with this response. It is necessary that the cycle be repeated until mk1 mk2 and mk3 satisfy the conditions. How to fix it?

fqdname=$(hostname -f); mk1='^.+\.localdomain$' mk2='^.{4,253}$' mk3='^([[:alnum:]][[:alnum:]\-]{0,61}[[:alnum:]]\.)+[a-zA-Z]{2,63}$' if [[ $fqdname =~ $mk1 ]]; then echo "Current hostname: $fqdname" echo -e "Warning: Top-level domain name cannot be *.localdomain" elif ! [[ $fqdname =~ $mk2 && $fqdname =~ $mk3 ]]; then echo "Current hostname: $fqdname" echo -e "Warning: Hostname is not a valid full name (FQDN)" fi if [[ $fqdname =~ $mk1 ]] || ! [[ $fqdname =~ $mk2 && $fqdname =~ $mk3 ]]; then while ! [[$line =~ $mk2 && $line =~ $mk3 ]]; do echo -n "Enter the correct FQDN (eg ${HOSTNAME%%.*}.example.com) or press Ctrl+C to cancel:" read -r line done hostnamectl set-hostname "$line" fi 

    0