diff --git a/scripts/install b/scripts/install index 231876a..6c36be4 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..ec0cb08 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:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." --time --weight=1 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #=================================================