Hostname Validation added

This commit is contained in:
Bram Prieshof
2020-07-15 13:30:40 +02:00
parent dff348abbe
commit d5a471ed1f

View File

@@ -128,6 +128,33 @@ else
fi fi
} }
function HostnameQuest {
if (whiptail --title "Config" --yesno " Hostname with nxdi.nl" 11 78); then
hostname=$(whiptail --nocancel --inputbox " SystemID (eg: VCH001) without ".nxdi.nl" " 11 82 --title "Config" 3>&1 1>&2 2>&3)
hostname=$hostname".nxdi.nl"
else
hostname=$(whiptail --nocancel --inputbox " Hostname" 11 78 --title "Config" 3>&1 1>&2 2>&3)
fi
}
function LegacyHostnameQuest {
while true; do
read -p "Hostname with nxdi.nl -> yes/no?" yn
case $yn in
[Nn]* )
echo 'Enter full hostname:'
read hostname
break;;
[Yy]* )
echo 'Hostname (eg: VCH001) without ".nxdi.nl":'
read hostname
hostname=$hostname".nxdi.nl"
break;;
* )echo "Choose yes or no.";;
esac
done
}
##--------------------------## ##--------------------------##
# Installer-Requirements # # Installer-Requirements #
@@ -148,13 +175,17 @@ source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/ModulesM
if [ $IMODE = n ]; then if [ $IMODE = n ]; then
if [ $TestMode = 0 ]; then if [ $TestMode = 0 ]; then
domain=$(whiptail --nocancel --inputbox " Enter the domain without WWW " 11 82 --title "Config" 3>&1 1>&2 2>&3) domain=$(whiptail --nocancel --inputbox " Enter the domain without WWW " 11 82 --title "Config" 3>&1 1>&2 2>&3)
if (whiptail --title "Config" --yesno " Does www.${domain} exist in DNS" 8 78); then domainwww=1; else domainwww=0; fi while true; do
if (whiptail --title "Config" --yesno " Hostname with nxdi.nl" 11 78); then HostnameQuest
hostname=$(whiptail --nocancel --inputbox " SystemID (eg: VCH001) without ".nxdi.nl" " 11 82 --title "Config" 3>&1 1>&2 2>&3) if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ]
hostname=$hostname".nxdi.nl" then
else whiptail --msgbox " Hostname can't be empty, or be the same as the domain" 11 78
hostname=$(whiptail --nocancel --inputbox " Hostname" 11 78 --title "Config" 3>&1 1>&2 2>&3) else
fi break
fi
done
if (whiptail --title "Config" --yesno " Enable SSL on installation?" 11 78); then if (whiptail --title "Config" --yesno " Enable SSL on installation?" 11 78); then
sslenable=1 sslenable=1
else else
@@ -184,19 +215,14 @@ while true; do
esac esac
done done
while true; do while true; do
read -p "Hostname with nxdi.nl -> yes/no?" yn LegacyHostnameQuest
case $yn in if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ]
[Nn]* ) then
echo 'Enter full hostname:' echo "Hostname can't be empty, or be the same as the domain"
read hostname else
break;; break
[Yy]* )
echo 'Hostname (eg: VCH001) without ".nxdi.nl":' fi
read hostname
hostname=$hostname".nxdi.nl"
break;;
* )echo "Choose yes or no.";;
esac
done done
while true; do while true; do
read -p "Enable SSL on installation? -> yes/no?" yn read -p "Enable SSL on installation? -> yes/no?" yn