From cf8edb4d78c999a178e3b375653b9ccd7d4a9da0 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Aug 2021 18:43:21 +0200 Subject: [PATCH] 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 #=================================================