diff options
| author | nemsia <nemsia@nemsia.org> | 2018-06-18 15:15:27 +0200 |
|---|---|---|
| committer | nemsia <nemsia@nemsia.org> | 2018-06-18 15:15:27 +0200 |
| commit | 2bd8279988875c5469f397dcd13259c3c26a4883 (patch) | |
| tree | 68b6efd4f33587b2a3640c791f2ac28761804cca | |
| parent | c9429cbf23826fb6552582708c1673b58644ff3f (diff) | |
| download | mastodon_ynh-2bd8279988875c5469f397dcd13259c3c26a4883.tar.gz mastodon_ynh-2bd8279988875c5469f397dcd13259c3c26a4883.tar.bz2 mastodon_ynh-2bd8279988875c5469f397dcd13259c3c26a4883.zip | |
Add pg user pass on upgrade
| -rw-r--r-- | scripts/upgrade | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/upgrade b/scripts/upgrade index 18f4d8e..5585e03 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,6 +16,7 @@ source /usr/share/yunohost/helpers # See comments in install script app=$YNH_APP_INSTANCE_NAME db_name=$(ynh_app_setting_get "$app" db_name) +db_pwd=$(ynh_app_setting_get "$app" db_pwd) # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) @@ -47,6 +48,15 @@ if [[ "$admin" = "" || "$language" = "" ]]; then ynh_die fi +# If db_pwd doesn't exist, create it +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 #================================================= |
