From 995a785c17bc5a6ca18deb5e3be4512e20e822d6 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Fri, 12 Mar 2021 11:48:12 -0500 Subject: [PATCH] passwd.sh --- scripts/install.sh | 8 +------- scripts/subinstallers/passwd.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100755 scripts/subinstallers/passwd.sh diff --git a/scripts/install.sh b/scripts/install.sh index e79b838..6d86774 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -59,13 +59,7 @@ echo -e "| | | | \__ \ |_| |_) | (_) | | | | | |" echo -e "|_| |_|_|___/\__|_.__/ \___/|_| |_| |_|" echo -e "" -# INPUT default admin password -if [ -z "${MISTBORN_DEFAULT_PASSWORD}" ]; then - read -p "(Mistborn) Set default admin password: " -s MISTBORN_DEFAULT_PASSWORD - echo -else - echo "MISTBORN_DEFAULT_PASSWORD is already set" -fi +source ./scripts/subinstallers/passwd.sh # Install Cockpit? if [ -z "${MISTBORN_INSTALL_COCKPIT}" ]; then diff --git a/scripts/subinstallers/passwd.sh b/scripts/subinstallers/passwd.sh new file mode 100755 index 0000000..5d8685e --- /dev/null +++ b/scripts/subinstallers/passwd.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# INPUT default admin password +while [ -z "${MISTBORN_DEFAULT_PASSWORD}" ]; do + echo "(Mistborn) The default admin password may only container alphanumeric characters and _" + read -p "(Mistborn) Set default admin password: " -s MISTBORN_DEFAULT_PASSWORD + echo + + if [[ $s =~ ^[A-Za-z_]+$ ]]; then + # it matches + echo "(Mistborn) Password is accepted" + else + unset MISTBORN_DEFAULT_PASSWORD + echo "(Mistborn) Try again" + fi + +done + +echo "MISTBORN_DEFAULT_PASSWORD is set"