From adbfeb00749ab7d0d0db1ca4cd6870ee8315446a Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 15 Feb 2024 18:05:03 +0900 Subject: [PATCH] Password length set, auto set if not set, and set for pwgen actually --- bin/create_user.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/create_user.sh b/bin/create_user.sh index 789e9a7..d4456e1 100755 --- a/bin/create_user.sh +++ b/bin/create_user.sh @@ -88,9 +88,11 @@ if [ ! -d "${HOME_FOLDER}" ]; then error=1; fi; # allow 10 to 39 length for password -if ! [[ "${PASSWORD_LENGTH}" =~ ^[13][0-9]$ ]] || [ -z ${PASSWORD_LENGTH} ]; then +if ! [[ "${PASSWORD_LENGTH}" =~ ^[13][0-9]$ ]]; then echo "Password length set error, can only be a value between 10 and 39"; error=1; +elif [ -z ${PASSWORD_LENGTH} ]; then + PASSWORD_LENGTH=14; fi; error=1; # home dir error abort @@ -315,7 +317,7 @@ while read i; do # Note we only create a password if we need it # password + store pwgen 10 1 -1 if [ -z "${_password}" ]; then - password=$(printf "%s" $(pwgen 14 1)); + password=$(printf "%s" $(pwgen ${PASSWORD_LENGTH} 1)); elif [ "${_password}" = "SET_NO_PASSWORD" ]; then # set empty echo "* No password set";