From cf8edb4d78c999a178e3b375653b9ccd7d4a9da0 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Aug 2021 18:43:21 +0200 Subject: [PATCH 1/5] Add purge option --- scripts/install | 5 +++-- scripts/remove | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 152003a..dcec64f 100755 --- a/scripts/install +++ b/scripts/install @@ -205,10 +205,11 @@ ynh_script_progression --message="Creating a data directory..." --time --weight= ### Use these lines if you need to create a directory to store "persistent files" for the application. ### Usually this directory is used to store uploaded files or any file that won't be updated during -### an upgrade and that won't be deleted during app removal +### an upgrade and that won't be deleted during app removal unless "--purge" option is used. ### If you're not using these lines: ### - Remove the section "BACKUP THE DATA DIR" in the backup script -### - As well as the section "RESTORE THE DATA DIRECTORY" in the restore script +### - Remove the section "RESTORE THE DATA DIRECTORY" in the restore script +### - As well as the section "REMOVE DATA DIR" in the remove script datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir diff --git a/scripts/remove b/scripts/remove index d53be6d..de5f420 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -75,6 +76,17 @@ ynh_script_progression --message="Removing app main directory..." --time --weigh # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the data directory if --purge option is used. +if [ "$YNH_APP_PURGE" == true ] +then + ynh_script_progression --message="Removing app data directory..." --time --weight=1 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= From c621c50c3af222f584c3c4a625a0f53b733fc782 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Aug 2021 18:50:54 +0200 Subject: [PATCH 2/5] Update remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index de5f420..0b03969 100755 --- a/scripts/remove +++ b/scripts/remove @@ -80,7 +80,7 @@ ynh_secure_remove --file="$final_path" # REMOVE DATA DIR #================================================= -# Remove the data directory if --purge option is used. +# Remove the data directory if --purge option is used if [ "$YNH_APP_PURGE" == true ] then ynh_script_progression --message="Removing app data directory..." --time --weight=1 From 4ab319384f13583a516d97e91d1020574b94ae4d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Aug 2021 20:02:18 +0200 Subject: [PATCH 3/5] Update remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 0b03969..e9312df 100755 --- a/scripts/remove +++ b/scripts/remove @@ -81,7 +81,7 @@ ynh_secure_remove --file="$final_path" #================================================= # Remove the data directory if --purge option is used -if [ "$YNH_APP_PURGE" == true ] +if [ "$YNH_APP_PURGE" == 1 ] then ynh_script_progression --message="Removing app data directory..." --time --weight=1 ynh_secure_remove --file="$datadir" From a4d415bf5c647ed49daf6e32926ebc45460c2166 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Aug 2021 20:09:35 +0200 Subject: [PATCH 4/5] Update remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index e9312df..43c57b4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -81,7 +81,7 @@ ynh_secure_remove --file="$final_path" #================================================= # Remove the data directory if --purge option is used -if [ "$YNH_APP_PURGE" == 1 ] +if [ "$YNH_APP_PURGE" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --time --weight=1 ynh_secure_remove --file="$datadir" From 3d3b319ab11beb93ca0893ef31330f2325c7e8de Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 24 Aug 2021 10:48:00 +0200 Subject: [PATCH 5/5] [enh] Compatibility with previous version --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 43c57b4..ec0cb08 100755 --- a/scripts/remove +++ b/scripts/remove @@ -81,7 +81,7 @@ ynh_secure_remove --file="$final_path" #================================================= # Remove the data directory if --purge option is used -if [ "$YNH_APP_PURGE" -eq 1 ] +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --time --weight=1 ynh_secure_remove --file="$datadir"