diff --git a/data/apps/helpers.d/password b/data/apps/helpers.d/password deleted file mode 100644 index b9a790885..000000000 --- a/data/apps/helpers.d/password +++ /dev/null @@ -1,7 +0,0 @@ - -# Generate a random password -# -# usage: ynh_password -ynh_password() { - echo $(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') -} diff --git a/data/apps/helpers.d/string b/data/apps/helpers.d/string new file mode 100644 index 000000000..a2bf0d463 --- /dev/null +++ b/data/apps/helpers.d/string @@ -0,0 +1,11 @@ +# Generate a random string +# +# example: pwd=$(ynh_string_random 8) +# +# usage: ynh_string_random [length] +# | arg: length - the string length to generate (default: 24) +ynh_string_random() { + dd if=/dev/urandom bs=1 count=200 2> /dev/null \ + | tr -c -d '[A-Za-z0-9]' \ + | sed -n 's/\(.\{'"${1:-24}"'\}\).*/\1/p' +}