From fb55b0b2f28955d2e76c3fa269913926fee2f9eb Mon Sep 17 00:00:00 2001 From: bprieshof Date: Wed, 18 Dec 2019 13:43:41 +0100 Subject: [PATCH] Added new password validator --- installer.sh | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/installer.sh b/installer.sh index 56ad16d..d3af984 100644 --- a/installer.sh +++ b/installer.sh @@ -30,6 +30,36 @@ echo "$1" fi } +function PasswordQuest { +passdiaone=$(whiptail --nocancel --passwordbox "Please enter your password (should contain at least 2 digits and 6 characters)" 11 82 --title "Config" 3>&1 1>&2 2>&3) +if [ -z $passdiaone ]; then PasswordQuest; fi +if [ ${#passdiaone} -lt 8 ]; then whiptail --ok-button Done --msgbox "Password is not long enough!" 10 30 && PasswordQuest;else PasswordCheck; fi +} +function PasswordCheck { +#Checking password +passdiatwo=$(whiptail --nocancel --passwordbox "Please re-enter your password" 11 82 --title "Config" 3>&1 1>&2 2>&3) +if [ -z $passdiatwo ]; then PasswordCheck; fi +if [ $passdiaone != $passdiatwo ]; then whiptail --ok-button Done --msgbox "Password does not match!" 10 30 && PasswordQuest; fi +password=$passdiaone +unset passdiaone passdiatwo +} + +function LegacyPasswordQuest { +echo "Please enter your password (should contain at least 2 digits and 6 characters)" +read -s passdiaone +if [ -z $passdiaone ]; then PasswordQuest; fi +if [ ${#passdiaone} -lt 8 ]; then echo "Password is not long enough!" && LegacyPasswordQuest;else LegacyPasswordCheck; fi +} +function LegacyPasswordCheck { +#Checking password +echo "Please re-enter your password" +read -s passdiatwo +if [ -z $passdiatwo ]; then LegacyPasswordCheck; fi +if [ $passdiaone != $passdiatwo ]; then echo "Password does not match!" && LegacyPasswordQuest; fi +password=$passdiaone +unset passdiaone passdiatwo +} + ##---------------## # Static-Vars # @@ -75,7 +105,7 @@ if (whiptail --title "Config" --yesno "Enable SSL on installation?" 11 82); then else sslenable=0 fi -password=$(whiptail --nocancel --passwordbox "Please enter your password (should contain at least 2 digits and 6 characters)" 11 82 --title "Config" 3>&1 1>&2 2>&3) +PasswordQuest email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 82 --title "Config" 3>&1 1>&2 2>&3) webserv=$(whiptail --title "Select Webserver" --radiolist "WebServer" 11 53 5 "Nginx:" "Will install NGINX Webserver." ON "Apache:" "Will install Apache Webserver." OFF 3>&1 1>&2 2>&3) esws=$? @@ -121,8 +151,7 @@ while true; do * ) echo "Choose yes of no.";; esac done -echo "Please enter your password (should contain at least 2 digits and 6 characters:" -read password +LegacyPasswordQuest echo "Administrator E-mail:" read email