Password length set, auto set if not set, and set for pwgen actually

This commit is contained in:
Clemens Schwaighofer
2024-02-15 18:05:03 +09:00
parent 8c7ef32894
commit adbfeb0074

View File

@@ -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";