Create user script update: allow no password, allow different password length

This commit is contained in:
Clemens Schwaighofer
2024-02-15 18:03:16 +09:00
parent 70ef7a3fc5
commit 8c7ef32894
2 changed files with 35 additions and 0 deletions

View File

@@ -87,6 +87,12 @@ if [ ! -d "${HOME_FOLDER}" ]; then
echo "Home folder location not found: ${HOME_FOLDER}";
error=1;
fi;
# allow 10 to 39 length for password
if ! [[ "${PASSWORD_LENGTH}" =~ ^[13][0-9]$ ]] || [ -z ${PASSWORD_LENGTH} ]; then
echo "Password length set error, can only be a value between 10 and 39";
error=1;
fi;
error=1;
# home dir error abort
if [ $error -eq 1 ]; then
exit;
@@ -310,6 +316,10 @@ while read i; do
# password + store pwgen 10 1 -1
if [ -z "${_password}" ]; then
password=$(printf "%s" $(pwgen 14 1));
elif [ "${_password}" = "SET_NO_PASSWORD" ]; then
# set empty
echo "* No password set";
password="";
else
echo "! Override password set";
password=${_password};