From 6b14609a39ce8f5ecaa94901853fe3d99dbf9456 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Jun 2022 21:07:01 +0200 Subject: [PATCH 1/4] Manage datadir --- conf/lufi.conf.template | 2 +- scripts/backup | 7 +++++++ scripts/install | 14 ++++++++++++++ scripts/remove | 12 ++++++++++++ scripts/restore | 14 ++++++++++++++ scripts/upgrade | 12 ++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/conf/lufi.conf.template b/conf/lufi.conf.template index b83da8d..6719efb 100644 --- a/conf/lufi.conf.template +++ b/conf/lufi.conf.template @@ -110,7 +110,7 @@ # Remember that it has to be in a directory writable by Lufi user # DO NOT CHANGE THIS IF FILES HAVE BEEN ALREADY UPLOADED: THEY WILL NOT BE DOWNLOADABLE ANYMORE # optional, default is 'files' - #upload_dir => 'files', + upload_dir => '__DATADIR__/upload', #!!!!!!!!!!!!!!! # EXPERIMENTAL ! diff --git a/scripts/backup b/scripts/backup index f50339b..a06ba98 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,6 +30,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) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -42,6 +43,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 85e4c9e..45609a6 100644 --- a/scripts/install +++ b/scripts/install @@ -121,6 +121,20 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir/upload + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # CONFIGURE LUFI #================================================= diff --git a/scripts/remove b/scripts/remove index f7d2e34..61314a5 100644 --- 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 @@ -67,6 +68,17 @@ ynh_script_progression --message="Removing app main directory..." # 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..." + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 7fc5f5f..40dc3e0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,6 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -63,6 +64,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..." + +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" + #================================================= # SPECIFIC RESTORATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f347ec9..ac887c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION @@ -113,6 +114,17 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +# If datadir doesn't exist, create it +if [ -z "$datadir" ]; then + datadir=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mkdir -p $datadir + mv -f "$final_path/upload" "$datadir/upload" + chmod 750 "$datadir" + chmod -R o-rwx "$datadir" + chown -R $app:www-data "$datadir" +fi + #================================================= # CREATE DEDICATED USER #================================================= From 0a90cd6c2b76fb7b56588c1f37f32aea6087db27 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 16 Jun 2022 19:07:06 +0000 Subject: [PATCH 2/4] Auto-update README --- README.md | 17 +++++++++-------- README_fr.md | 23 ++++++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 61a5fc0..6bcb16b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Lufi for YunoHost -[![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![Working status](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) [![Install Lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lufi) *[Lire ce readme en français.](./README_fr.md)* @@ -29,7 +29,7 @@ The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https: ## Screenshots -![](./doc/screenshots/screenshot_lufi_1.png) +![Screenshot of Lufi](./doc/screenshots/screenshot_lufi_1.png) ## Disclaimers / important information @@ -39,20 +39,21 @@ The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https: ## Documentation and resources -* Official admin documentation: https://framagit.org/luc/lufi/wikis/home -* Upstream app code repository: https://framagit.org/fiat-tux/hat-softwares/lufi -* YunoHost documentation for this app: https://yunohost.org/app_lufi -* Report a bug: https://github.com/YunoHost-Apps/lufi_ynh/issues +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lufi_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug or sudo yunohost app upgrade lufi -u https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index f08a756..be1b35b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Lufi pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) [![Installer Lufi avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lufi) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer Lufi rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* @@ -25,7 +29,7 @@ The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https: ## Captures d'écran -![](./doc/screenshots/screenshot_lufi_1.png) +![Capture d'écran de Lufi](./doc/screenshots/screenshot_lufi_1.png) ## Avertissements / informations importantes @@ -35,20 +39,21 @@ The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https: ## Documentations et ressources -* Documentation officielle de l'admin : https://framagit.org/luc/lufi/wikis/home -* Dépôt de code officiel de l'app : https://framagit.org/fiat-tux/hat-softwares/lufi -* Documentation YunoHost pour cette app : https://yunohost.org/app_lufi -* Signaler un bug : https://github.com/YunoHost-Apps/lufi_ynh/issues +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lufi_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug ou sudo yunohost app upgrade lufi -u https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** From 13012b14f31441a2d72c274c10e3da5a43fa444a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 19 Jun 2022 01:22:47 +0200 Subject: [PATCH 3/4] Update change_url --- scripts/change_url | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/change_url b/scripts/change_url index 7f21894..ecf19ea 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,6 +37,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_user=$db_name secret=$(ynh_app_setting_get --app=$app --key=secret) max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP From a2984f8adfc07a4dd5f62f2a99b42075a8ecfb31 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 19 Jun 2022 01:38:03 +0200 Subject: [PATCH 4/4] fix files --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index ac887c1..c31355e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -119,7 +119,7 @@ if [ -z "$datadir" ]; then datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir mkdir -p $datadir - mv -f "$final_path/upload" "$datadir/upload" + mv -f "$final_path/files" "$datadir/upload" chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:www-data "$datadir"