From b25671e9221ee8fe40db9e92c86721f32c53bb83 Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 8 Aug 2022 13:15:21 -0400 Subject: [PATCH 1/4] fix upgrade --- check_process | 2 +- scripts/upgrade | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/check_process b/check_process index ac4363b..6cd9557 100644 --- a/check_process +++ b/check_process @@ -8,7 +8,7 @@ setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 backup_restore=1 diff --git a/scripts/upgrade b/scripts/upgrade index 588489a..d373b35 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -104,14 +104,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config - #================================================= # NGINX CONFIGURATION #================================================= @@ -130,8 +122,8 @@ ynh_add_config --template=".env.template" --destination="$final_path/.env" # FIXME: this should be handled by the core in the future # You may need to use chmod 600 instead of 400, # for example if the app is expected to be able to modify its own config -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" #================================================= # SPECIFIC UPGRADE From 92e3f76d836cb2494942bb31e233bfbafe4b426f Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Tue, 9 Aug 2022 13:40:43 -0400 Subject: [PATCH 2/4] initialise vars --- scripts/restore | 3 +++ scripts/upgrade | 3 +++ 2 files changed, 6 insertions(+) diff --git a/scripts/restore b/scripts/restore index e1667d7..4c0114c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,12 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) db_user=$db_name #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d373b35..e69daa0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,9 +17,12 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) #================================================= # CHECK VERSION From 824daad3a5dd3cc44b5fbfd2fc25f57ac0f5fe84 Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Tue, 9 Aug 2022 13:52:43 -0400 Subject: [PATCH 3/4] call ynh_psql_test_if_first_run --- scripts/install | 1 + scripts/restore | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 9b5cfe4..b8e7c4c 100755 --- a/scripts/install +++ b/scripts/install @@ -94,6 +94,7 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_psql_execute_as_root --sql="GRANT ALL PRIVILEGES ON DATABASE $db_user TO $db_user;" diff --git a/scripts/restore b/scripts/restore index 4c0114c..c60e202 100755 --- a/scripts/restore +++ b/scripts/restore @@ -95,6 +95,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql From b065a956d33f7a98ca724864bc51e553e53dc60b Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Tue, 9 Aug 2022 16:40:16 -0400 Subject: [PATCH 4/4] fixed psql pwd --- scripts/restore | 2 +- scripts/upgrade | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/restore b/scripts/restore index c60e202..5f2ef60 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) db_user=$db_name diff --git a/scripts/upgrade b/scripts/upgrade index e69daa0..52d3ab8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) secretkey=$(ynh_app_setting_get --app=$app --key=secretkey) #================================================= @@ -135,11 +135,10 @@ chown $app:$app "$final_path/.env" if [ "$upgrade_type" == "UPGRADE_APP" ] then - # load environment variables - export $(cat "/var/www/$app/.env" |grep "^[^#]" | xargs) - ynh_script_progression --message="Running migrations and generatic static files..." --weight=2 pushd "$final_path" + # load environment variables + export $(cat "/var/www/$app/.env" |grep "^[^#]" | xargs) ynh_exec_as $app "$final_path/venv/bin/python3" manage.py migrate ynh_exec_as $app "$final_path/venv/bin/python3" manage.py collectstatic --no-input ynh_exec_as $app "$final_path/venv/bin/python3" manage.py collectstatic_js_reverse