From dd78dad684b7a1501f369b8e50473c489a16c3b7 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Thu, 16 Mar 2017 14:38:19 +0100 Subject: [PATCH] Ajouter la fonction GENERATE_DB --- scripts/.fonctions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/.fonctions b/scripts/.fonctions index 755b5bd..629e49e 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -59,6 +59,21 @@ ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null eval "$@" > /dev/null 2>&1 } +#================================================= +# Create a database and a dedicated user in the name of the app +#================================================= +GENERATE_DB () { + # $1 = Database name + # Generates a random password. + db_user=$1 + db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20) + CHECK_VAR "$db_pwd" "db_pwd empty" + # Uses '$ app' as user name and database + # Initializes the database and stores the mysql password. + ynh_mysql_create_db "$db_user" "$db_user" $db_pwd + ynh_app_setting_set $app mysqlpwd $db_pwd +} + #================================================= # SETUP #=================================================