From 4b2122d82b38ff20e07977596d0471e66f67a514 Mon Sep 17 00:00:00 2001 From: anmol Date: Sun, 4 Nov 2018 23:30:21 +0530 Subject: [PATCH] Random string in common.sh --- scripts/_common.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index c726850..6cd0293 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,6 +12,14 @@ ynh_delete_file_checksum () { ynh_app_setting_delete $app $checksum_setting_name } +# usage: ynh_string_random [length] +# | arg: length - the string length to generate (default: 24) +ynh_string_random() { + dd if=/dev/urandom bs=1 count=1000 2> /dev/null \ + | tr -c -d 'A-Za-z0-9' \ + | sed -n 's/\(.\{'"${1:-24}"'\}\).*/\1/p' +} + # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients]