[enh] Rename ynh_password bash helper to ynh_string_random

This commit is contained in:
Jérôme Lebleu 2015-11-30 21:23:55 +01:00
parent 3cf32aec26
commit 36bacba93f
2 changed files with 11 additions and 7 deletions

View file

@ -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')
}

View file

@ -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'
}