From f13690c38b42b07b75598018c85b4b84a88c3d24 Mon Sep 17 00:00:00 2001 From: nemsia Date: Thu, 21 Jun 2018 11:08:52 +0200 Subject: [PATCH 1/2] Add $db_pwd compatibility --- scripts/upgrade | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 0f99bab..0350efe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,6 +50,14 @@ if [[ "$admin" = "" || "$language" = "" ]]; then ynh_die fi +# If db_pwd doesn't exist, create it, need for old install +if [[ -z "$db_pwd" ]]; then + db_pwd=$(ynh_string_random) + ynh_app_setting_set $app db_pwd $db_pwd + ynh_psql_test_if_first_run + sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres + sed -i "s@DB_PASS=@DB_PASS=${db_pwd}@g" "${final_path}/live/.env.production" +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP From fc1dee56d6d0885aedf7525515a9eff7fcda895b Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Fri, 22 Jun 2018 14:00:26 +0530 Subject: [PATCH 2/2] used ynh_replace_string in upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0350efe..0429013 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,7 +56,7 @@ if [[ -z "$db_pwd" ]]; then ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres - sed -i "s@DB_PASS=@DB_PASS=${db_pwd}@g" "${final_path}/live/.env.production" + ynh_replace_string "DB_PASS=" "DB_PASS=${db_pwd}" "${final_path}/live/.env.production" fi #=================================================