From d963f0799257898b2d74ae3f67f8d51ba932d74c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 28 Aug 2021 18:56:58 +0200 Subject: [PATCH 1/3] Add datatdir --- conf/php-fpm.conf | 1 + scripts/backup | 7 +++++++ scripts/install | 14 ++++++++++++++ scripts/restore | 14 ++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 7f2c855..a982348 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -431,3 +431,4 @@ php_admin_value[post_max_size] = 1G ; env[IFM_AUTH] = 1 ; env[IFM_AUTH_SOURCE] = ldap;127.0.0.1:389;ou=users,dc=yunohost,dc=org;(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)) +env[IFM_ROOT_DIR] = /home/yunohost.app/__APP__ diff --git a/scripts/backup b/scripts/backup index 75ce3e0..0e4f0f0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,6 +27,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -39,6 +40,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index d97636f..2da932c 100755 --- a/scripts/install +++ b/scripts/install @@ -86,6 +86,20 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." --weight=1 + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/restore b/scripts/restore index e0a7127..4d8ef9b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,6 +28,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -67,6 +68,19 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= From 326932dccd13d9a6ea1cef0541ef1b59e068c0ed Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 28 Aug 2021 19:06:49 +0200 Subject: [PATCH 2/3] Fix --- manifest.json | 2 +- scripts/remove | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ff30d8a..5b43a7a 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,7 @@ "email": "" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.2.8" }, "multi_instance": true, "services": [ diff --git a/scripts/remove b/scripts/remove index 4a7848b..df0dd73 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # REMOVE APP MAIN DIR @@ -27,6 +28,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the app data directory with the command `yunohost app remove --purge` +if [ "$YNH_APP_PURGE" == true ] +then + ynh_script_progression --message="Removing $app data directory..." --weight=2 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= From ff03ecb269e8e0ccbe9e4942a0f41e5d9e59baff Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 28 Aug 2021 19:09:25 +0200 Subject: [PATCH 3/3] Update remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index df0dd73..cd0fc9e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -33,7 +33,7 @@ ynh_secure_remove --file="$final_path" #================================================= # Remove the app data directory with the command `yunohost app remove --purge` -if [ "$YNH_APP_PURGE" == true ] +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing $app data directory..." --weight=2 ynh_secure_remove --file="$datadir"