From de87924afbdc8ea1543a502bab43a24c0116fdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Mon, 1 Apr 2024 15:03:51 +0200 Subject: [PATCH] db_user is needed as well --- scripts/install | 9 ++++----- scripts/upgrade | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index b3ad97a..b6a9c5a 100755 --- a/scripts/install +++ b/scripts/install @@ -46,11 +46,13 @@ chown -R $app:www-data "$data_dir" #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -# Let's create all databases needed, and assign them to the user +# The .env needs db_user and db_password new_db_pwd=$(ynh_string_random) # Generate a random password - # If $db_pwd is not provided, use new_db_pwd instead for db_pwd db_pwd="${db_pwd:-$new_db_pwd}" +db_user=$(ynh_sanitize_dbid --db_name="${app}") +ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" + ynh_add_config --template=".env" --destination="$install_dir/.env" chmod 400 "$install_dir/.env" @@ -87,9 +89,6 @@ ynh_install_mongo --mongo_version=$mongo_version #================================================= ynh_script_progression --message="Creating the Mongo databases..." --weight=1 -db_user=$(ynh_sanitize_dbid --db_name="${app}") -ynh_app_setting_set --app="$app" --key=db_user --value="$db_user" - for db_name in "${MONGO_DB_LIST[@]}"; do ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}" done diff --git a/scripts/upgrade b/scripts/upgrade index 2d68f78..29459ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -40,8 +40,8 @@ if [ -z "${tenant+x}" ]; then ynh_app_setting_set --app="$app" --key=tenant --value="$tenant" fi +# The .env needs db_password new_db_pwd=$(ynh_string_random) # Generate a random password - # If $db_pwd is not provided, use new_db_pwd instead for db_pwd db_pwd="${db_pwd:-$new_db_pwd}" if [[ -n "${document_path:-}" ]]; then