diff --git a/installer.sh b/installer.sh index 41155ea..b12ceed 100644 --- a/installer.sh +++ b/installer.sh @@ -128,6 +128,33 @@ else 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 # @@ -148,13 +175,17 @@ source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/ModulesM if [ $IMODE = n ]; then if [ $TestMode = 0 ]; then 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 -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 +while true; do + HostnameQuest + if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ] + then + whiptail --msgbox " Hostname can't be empty, or be the same as the domain" 11 78 + else + break + + fi +done + if (whiptail --title "Config" --yesno " Enable SSL on installation?" 11 78); then sslenable=1 else @@ -184,19 +215,14 @@ while true; do esac done 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 + LegacyHostnameQuest + if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ] + then + echo "Hostname can't be empty, or be the same as the domain" + else + break + + fi done while true; do read -p "Enable SSL on installation? -> yes/no?" yn