Make manager hostname error more specific

This commit is contained in:
William Wernert
2021-11-08 10:35:28 -05:00
parent ad71485361
commit 50b7779d6e
2 changed files with 20 additions and 5 deletions

View File

@@ -470,11 +470,16 @@ collect_int_ip_mask() {
collect_mngr_hostname() { collect_mngr_hostname() {
whiptail_management_server whiptail_management_server
while ! valid_hostname "$MSRV" || [[ $MSRV == "$HOSTNAME" || $MSRVIP == "localhost" ]]; do while ! valid_hostname "$MSRV"; do
whiptail_invalid_hostname whiptail_invalid_hostname
whiptail_management_server "$MSRV" whiptail_management_server "$MSRV"
done done
while [[ $MSRV == "$HOSTNAME" || $MSRVIP == "localhost" ]]; do
whiptail_invalid_hostname 0
whiptail_management_server "$MSRV"
done
if ! getent hosts "$MSRV"; then if ! getent hosts "$MSRV"; then
whiptail_manager_ip whiptail_manager_ip

View File

@@ -841,7 +841,6 @@ whiptail_invalid_input() { # TODO: This should accept a list of arguments to spe
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
whiptail --title "$whiptail_title" --msgbox " Invalid input, please try again." 7 40 whiptail --title "$whiptail_title" --msgbox " Invalid input, please try again." 7 40
} }
whiptail_invalid_proxy() { whiptail_invalid_proxy() {
@@ -888,10 +887,21 @@ whiptail_invalid_user_warning() {
whiptail_invalid_hostname() { whiptail_invalid_hostname() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
local is_manager_hostname
is_manager_hostname="$1"
local error_message local error_message
error_message=$(echo "Please choose a valid hostname. It cannot be localhost; and must contain only \ read -r -d '' error_message <<- EOM
the ASCII letters 'A-Z' and 'a-z' (case-sensitive), the digits '0' through '9', \ Please choose a valid hostname. It cannot be localhost; and must contain only the ASCII letters 'A-Z' and 'a-z' (case-sensitive), the digits '0' through '9', and hyphen ('-')
and hyphen ('-')" | tr -d '\t') EOM
if [[ $is_manager_hostname = 0 ]]; then
local error_message
read -r -d '' error_message <<- EOM
Please enter a valid hostname. The manager hostname cannot be localhost or the chosen hostname for this machine.
EOM
fi
whiptail --title "$whiptail_title" \ whiptail --title "$whiptail_title" \
--msgbox "$error_message" 10 75 --msgbox "$error_message" 10 75