From aa4a7ab2cc2cb2a53b7b221d6c3307724fffe137 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Thu, 24 Jan 2019 08:56:59 +0100 Subject: [PATCH] simplier and safer code upgrade process --- scripts/restore | 1 + scripts/upgrade | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/restore b/scripts/restore index 319d9e0..fc5bcef 100644 --- a/scripts/restore +++ b/scripts/restore @@ -79,6 +79,7 @@ then mv "$final_path/media" "$final_path/code/data/media" mv "$final_path/import" "$final_path/code/data/music" ynh_secure_remove "$final_path/code" + ynh_app_setting_delete "$app" code_migration fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index edbd09d..c43b2b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ db_user=$db_name port=$(ynh_app_setting_get "$app" port) db_pwd=$(ynh_app_setting_get "$app" psqlpwd) redis_db=$(ynh_app_setting_get "$app" redis_db) +code_migration=$(ynh_app_setting_get "$app" code_migration) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -37,10 +38,15 @@ fi # make sure we have the last code organization if [ ! -d "$final_path/code/" ]; then + mkdir "$final_path-tmp" + mv "$final_path"/* "$final_path-tmp/" + mkdir "$final_path/code" - mv "$final_path"/!(code) "$final_path/code/" - mv "$final_path/code/data/media" "$final_path/media" - mv "$final_path/code/data/music" "$final_path/import" + mv "$final_path-tmp/data/media" "$final_path/media" + mv "$final_path-tmp/data/music" "$final_path/import" + mv "$final_path-tmp"/* "$final_path/code" + + ynh_secure_remove "$final_path-tmp/" ynh_app_setting_set "$app" code_migration 1 fi @@ -266,4 +272,4 @@ systemctl reload nginx # REMOVE CODE MIGRATION FLAG #================================================= -ynh_app_setting_delete "$app" code_migration \ No newline at end of file +ynh_app_setting_set "$app" code_migration 2 \ No newline at end of file