diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index d4e22b3..5d3fb23 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ + + # Jirafeau for YunoHost [![Integration level](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.maintain.svg) @@ -5,53 +10,43 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Jirafeau quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Jirafeau quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Jirafeau is a web site permitting to upload a file in a simple way and give an unique link to it. +Jirafeau offers the possibility to host and share your files with ease. Choose a file, Jirafeau will provide you with a link with many options. It is possible to protect your links with a password as well as to choose how long the file will be kept on the server. The file and the link will self-destruct after this time. Downloads of transmitted files can be limited to a certain date, and each file can self-destruct after the first download. Jirafeau allows you to configure maximum retention times and maximum size per file. Encryption is available as an option. -**Shipped version:** 4.3.0 + +**Shipped version:** 4.3.0~ynh3 + +**Demo:** https://demo.yunohost.org/jirafeau/ ## Screenshots -![](http://i.imgur.com/TPjh48P.png) +![](./doc/screenshots/TPjh48P.png) -## Demo - -* [YunoHost demo](https://demo.yunohost.org/jirafeau/) +## Disclaimers / important information ## Configuration -## Documentation +### Changing the conditions of use of the service - * Official documentation: - * YunoHost documentation: https://yunohost.org/en/app_jirafeau +The license text on the "Terms of Service" page, which is shipped with the default installation, is "based on the Open Source Initiative Terms of Service". To change this text simply copy the file `/lib/tos.original.txt`, rename it to `/lib/tos.local.txt` and adapt it to your own needs. If you update the installation, then only the `tos.original.txt` file may change eventually, not your `tos.local.txt file`. -## YunoHost specific features +## Administration -#### Supported architectures +To administer the files within Jirafeau it is enough to go to the address `jirafeau.domaine.tld/admin.php`. +## Documentation and resources -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/) +* Official app website: https://gitlab.com/mojo42/Jirafeau +* Upstream app code repository: https://gitlab.com/mojo42/Jirafeau +* YunoHost documentation for this app: https://yunohost.org/app_jirafeau +* Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues -## Limitations +## Developer info -## Additional information - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues - * Jirafeau website: https://gitlab.com/mojo42/Jirafeau - * Upstream app repository: https://gitlab.com/mojo42/Jirafeau - * YunoHost website: https://yunohost.org/ - ---- - -## Developers info - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -59,3 +54,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/jirafeau_ynh/tree/tes or sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 5c7d08b..982f6ad 100644 --- a/README_fr.md +++ b/README_fr.md @@ -3,51 +3,42 @@ [![Niveau d'intégration](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.maintain.svg) [![Installer Jirafeau avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=jirafeau) -*[Read this readme in english.](./README.md)* +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Jirafeau rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d'installer Jirafeau 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.* ## Vue d'ensemble -Jirafeau est un site web permettant d'héberger et de partager des fichiers de manière simple en leur donnant un lien unique. +Jirafeau offre la possibilité d'héberger et de partager vos fichiers, le tout en toute simplicité. Choisissez un fichier, Jirafeau vous fournira un lien avec beaucoup d'options. Il est possible de protéger vos liens avec mot de passe ainsi que de choisir la durée de rétention du fichier sur le serveur. Le fichier et le lien s'autodétruiront passé ce délai. Les téléchargements des fichiers transmis peuvent être limités à une certaine date, et chaque fichier peut s'autodétruire après le premier téléchargement. Jirafeau permet de configurer les temps maximum de rétention ainsi que la taille maximale par fichier. Le chiffrement est disponible en option. -**Version incluse :** 4.3.0 + +**Version incluse :** 4.3.0~ynh3 + +**Démo :** https://demo.yunohost.org/jirafeau/ ## Captures d'écran -![](http://i.imgur.com/TPjh48P.png) +![](./doc/screenshots/TPjh48P.png) -## Démo - -* [Démo officielle](https://demo.yunohost.org/jirafeau/) +## Avertissements / informations importantes ## Configuration -## Documentation +### Changer les conditions d'utilisation du service - * Documentation officielle : - * Documentation YunoHost : https://yunohost.org/fr/app_jirafeau +Le texte de la licence sur la page "Conditions d'utilisation du service", qui est livrée avec l'installation par défaut, est basé sur les "Conditions d'utilisation du service de l'Initiative Open Source". Pour modifier ce texte, il suffit de copier le fichier `/lib/tos.original.txt`, de le renommer en `/lib/tos.local.txt` et de l'adapter à vos propres besoins. Si vous mettez à jour l'installation, alors seul le fichier `tos.original.txt` peut changer éventuellement, et non votre fichier `tos.local.txt`. -## Caractéristiques spécifiques YunoHost +## Administration -#### Architectures supportées +Pour administrer les fichiers présents au sein de Jirafeau il suffit de se rendre à l'adresse `jirafeau.domaine.tld/admin.php`. +## Documentations et ressources -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/) - -## Limitations - -## Informations additionnelles - -## Liens - - * Signaler un bug : https://github.com/YunoHost-Apps/jirafeau_ynh/issues - * Site de l'application : https://gitlab.com/mojo42/Jirafeau - * Dépôt de l'application principale : https://gitlab.com/mojo42/Jirafeau - * Site web YunoHost : https://yunohost.org/ - ---- +* Site officiel de l'app : https://gitlab.com/mojo42/Jirafeau +* Dépôt de code officiel de l'app : https://gitlab.com/mojo42/Jirafeau +* Documentation YunoHost pour cette app : https://yunohost.org/app_jirafeau +* Signaler un bug : https://github.com/YunoHost-Apps/jirafeau_ynh/issues ## Informations pour les développeurs @@ -59,3 +50,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/jirafeau_ynh/tree/tes ou sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index f518524..f0f98f2 100644 --- a/check_process +++ b/check_process @@ -1,10 +1,10 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin_user="package_checker" (USER) + domain="domain.tld" + path="/path" + admin_user="package_checker" upload_password="supersecretpassword" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/app.src b/conf/app.src index 5a7af15..16a8307 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,3 @@ SOURCE_SUM=77bd4b69cb822ac8cac9df6890f17a673c978b10d8dd6fce46b60c763b859f74 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/config.local.php b/conf/config.local.php index fd209dd..80ba5c6 100644 --- a/conf/config.local.php +++ b/conf/config.local.php @@ -31,7 +31,7 @@ $cfg['web_root'] = 'https://' . '__DOMAIN__' . '__PATH__' . '/'; /* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264« */ -$cfg['var_root'] = '__VAR_ROOT__' . '/'; +$cfg['var_root'] = '__DATADIR__' . '/'; /* Language - choice between 'auto' or any language located in the /lib/locales/ folder. * The mode »auto« will cause the script to detect the user's browser information diff --git a/conf/nginx.conf b/conf/nginx.conf index ecb2372..c92f5a3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/ ; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - client_max_body_size 10G; client_body_timeout 30m; proxy_read_timeout 30m; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..6a49aff --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Jirafeau offers the possibility to host and share your files with ease. Choose a file, Jirafeau will provide you with a link with many options. It is possible to protect your links with a password as well as to choose how long the file will be kept on the server. The file and the link will self-destruct after this time. Downloads of transmitted files can be limited to a certain date, and each file can self-destruct after the first download. Jirafeau allows you to configure maximum retention times and maximum size per file. Encryption is available as an option. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..b3f5a7b --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Jirafeau offre la possibilité d'héberger et de partager vos fichiers, le tout en toute simplicité. Choisissez un fichier, Jirafeau vous fournira un lien avec beaucoup d'options. Il est possible de protéger vos liens avec mot de passe ainsi que de choisir la durée de rétention du fichier sur le serveur. Le fichier et le lien s'autodétruiront passé ce délai. Les téléchargements des fichiers transmis peuvent être limités à une certaine date, et chaque fichier peut s'autodétruire après le premier téléchargement. Jirafeau permet de configurer les temps maximum de rétention ainsi que la taille maximale par fichier. Le chiffrement est disponible en option. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e2c3b48 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,9 @@ +## Configuration + +### Changing the conditions of use of the service + +The license text on the "Terms of Service" page, which is shipped with the default installation, is "based on the Open Source Initiative Terms of Service". To change this text simply copy the file `/lib/tos.original.txt`, rename it to `/lib/tos.local.txt` and adapt it to your own needs. If you update the installation, then only the `tos.original.txt` file may change eventually, not your `tos.local.txt file`. + +## Administration + +To administer the files within Jirafeau it is enough to go to the address `jirafeau.domaine.tld/admin.php`. \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..1e3e5db --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,9 @@ +## Configuration + +### Changer les conditions d'utilisation du service + +Le texte de la licence sur la page "Conditions d'utilisation du service", qui est livrée avec l'installation par défaut, est basé sur les "Conditions d'utilisation du service de l'Initiative Open Source". Pour modifier ce texte, il suffit de copier le fichier `/lib/tos.original.txt`, de le renommer en `/lib/tos.local.txt` et de l'adapter à vos propres besoins. Si vous mettez à jour l'installation, alors seul le fichier `tos.original.txt` peut changer éventuellement, et non votre fichier `tos.local.txt`. + +## Administration + +Pour administrer les fichiers présents au sein de Jirafeau il suffit de se rendre à l'adresse `jirafeau.domaine.tld/admin.php`. \ No newline at end of file diff --git a/doc/screenshots/TPjh48P.png b/doc/screenshots/TPjh48P.png new file mode 100644 index 0000000..0c7605d Binary files /dev/null and b/doc/screenshots/TPjh48P.png differ diff --git a/manifest.json b/manifest.json index b736cd7..f520de8 100644 --- a/manifest.json +++ b/manifest.json @@ -6,15 +6,21 @@ "en": "Upload a file in a simple way and give a unique link to it", "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique" }, - "version": "4.3.0~ynh2", + "version": "4.3.0~ynh3", "url": "https://gitlab.com/mojo42/Jirafeau", + "upstream": { + "license": "AGPL-3.0-only", + "website": "https://gitlab.com/mojo42/Jirafeau", + "demo": "https://demo.yunohost.org/jirafeau/", + "code": "https://gitlab.com/mojo42/Jirafeau" + }, "license": "AGPL-3.0-only", "maintainer": { "name": "julien", "email": "julien.malik@paraiso.me" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ @@ -25,8 +31,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -40,18 +45,16 @@ "ask": { "en": "Choose an admin user (will be able to access admin.php page)", "fr": "Choisissez l'administrateur (seul autorisé à accéder à la page admin.php)" - }, - "example": "johndoe" + } }, { "name": "upload_password", "type": "password", "optional": true, "ask": { - "en": "Set the password granting upload permissions (leave empty to allow anybody to upload)", - "fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde)" - }, - "example": "supersecretpassword" + "en": "Set the password granting upload permissions (leave empty to allow anybody to upload). Please avoid using ' (quotes) in the password as it will fail the app...", + "fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde). Veuillez éviter d'utiliser ' (guillemets) dans le mot de passe car cela fera échouer l'application..." + } }, { "name": "is_public", diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 0a198cf..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how you fix that* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/backup b/scripts/backup index b4e5a99..91246d8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,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 @@ -40,7 +41,7 @@ ynh_backup --src_path="$final_path" # BACKUP OF THE DATA DIR #================================================= -ynh_backup --src_path="/home/yunohost.app/$app" --is_big +ynh_backup --src_path="$datadir" --is_big #================================================= # BACKUP OF THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index cec41ff..9891e2e 100755 --- a/scripts/install +++ b/scripts/install @@ -23,9 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin_user=$YNH_APP_ARG_ADMIN_USER -ynh_print_OFF upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD -ynh_print_ON is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -51,6 +49,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin_user ynh_app_setting_set --app=$app --key=is_public --value=$is_public +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=2 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -62,6 +68,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -70,14 +80,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=2 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -97,7 +99,6 @@ jirafeauconfigfile="$final_path/lib/config.local.php" cp "../conf/config.local.php" "$jirafeauconfigfile" # Set and save upload password, allowing an empty one -ynh_print_OFF if [ -z "$upload_password" ] then ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" @@ -106,15 +107,26 @@ else ynh_replace_special_string --match_string="__UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile" ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password" fi -ynh_print_ON + +#================================================= +# 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/{files,links,async,block} + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # CONFIGURE JIRAFEAU #================================================= ynh_script_progression --message="Configuring Jirafeau..." --weight=2 -var_root=/home/yunohost.app/$app - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile" if [ "$path_url" = "/" ] then @@ -122,7 +134,7 @@ then else ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" fi -ynh_replace_string --match_string="__VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile" +ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$jirafeauconfigfile" ynh_replace_string --match_string="__ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile" # Calculate and store the config file checksum into the app settings @@ -131,24 +143,17 @@ ynh_store_file_checksum --file="$jirafeauconfigfile" # Remove the install.php ynh_secure_remove --file=$final_path/install.php +chmod 400 "$jirafeauconfigfile" +chown $app:$app "$jirafeauconfigfile" + #================================================= # SET THE CRON FILE #================================================= ynh_script_progression --message="Configuring the cron file..." --weight=2 ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" - -#================================================= -# GENERIC FINALISATION -#================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -chown -R root: $final_path - -mkdir -p $var_root/{files,links,async,block} -chown -R $app:root $var_root -chmod -R 700 $var_root +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 9e6c2bc..f7a2c97 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,17 +18,29 @@ 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) #================================================= # STANDARD REMOVE #================================================= # REMOVE THE MAIN DIR OF THE APP #================================================= -ynh_script_progression --message="Removing Jirafeau main directory..." --weight=2 +ynh_script_progression --message="Removing app main directory..." --weight=2 # 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..." --weight=1 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= @@ -52,15 +64,6 @@ ynh_script_progression --message="Removing the cron file..." --weight=1 ynh_secure_remove --file="/etc/cron.d/$app" -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE THE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Removing data directory..." --weight=1 - -ynh_secure_remove --file="/home/yunohost.app/$app" - #================================================= # GENERIC FINALISATION #================================================= @@ -75,4 +78,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Jirafeau completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 89783b5..9c38fa6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,14 +26,13 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) 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 #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -42,27 +41,46 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring Jirafeau main directory..." --weight=2 - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring $app main directory..." --weight=2 + +ynh_restore_file --origin_path="$final_path" + +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/{files,links,async,block}" + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" @@ -74,26 +92,8 @@ ynh_add_fpm_config ynh_script_progression --message="Restoring the cron file..." --weight=1 ynh_restore_file --origin_path="/etc/cron.d/$app" - -#================================================= -# SPECIFIC RESTORE -#================================================= -# RESTORE THE DATA OF JIRAFEAU -#================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=2 - -datadir="/home/yunohost.app/$app" - -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. -ynh_restore_file --origin_path="$datadir" --not_mandatory - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Create app folders -mkdir -p "$datadir"/{files,links,async,block} -chown -R $app:root /home/yunohost.app/$app +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # GENERIC FINALISATION @@ -109,4 +109,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Jirafeau" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index b80e9be..4fd4e8f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,10 +21,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin_user=$(ynh_app_setting_get --app=$app --key=admin) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -ynh_print_OFF upload_password=$(ynh_app_setting_get --app=$app --key=upload_password) -ynh_print_ON phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION @@ -32,26 +31,37 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up Jirafeau before upgrading (may take a while)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path 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 +fi + # Migrate files from 3.4.1 to 4.1.1 current_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")" update_version="$(ynh_app_upstream_version)" @@ -60,8 +70,6 @@ if [ ${current_version:0:1} -le 3 ] && [ ${update_version:0:1} -ge 4 ] then ynh_script_progression --message="Migrating files..." --weight=5 - var_root=/home/yunohost.app/$app - # Migrate files and links to the new directory structure for type in files links do @@ -78,7 +86,7 @@ then # Split the file name every 8 characters split=0 - full_path="$var_root/$type" + full_path="$datadir/$type" while [ $split -le ${#file} ] do part_dir="${file:$split:8}" @@ -94,7 +102,7 @@ then if [ "$type" = "files" ]; then mv "${full_file}_count" "$full_path" fi - done <<< "$(find "$var_root/$type" -type f)" # List all files, without directories + done <<< "$(find "$datadir/$type" -type f)" # List all files, without directories done # And clean the old directories @@ -109,23 +117,17 @@ then then ynh_secure_remove --file="$file" fi - done <<< "$(find "$var_root/$type" -maxdepth 1 -mindepth 1 -type d)" # List all first level directories + done <<< "$(find "$datadir/$type" -maxdepth 1 -mindepth 1 -type d)" # List all first level directories done fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up Jirafeau before upgrading (may take a while)..." --weight=3 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # STANDARD UPGRADE STEPS @@ -141,6 +143,10 @@ then ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -149,14 +155,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -178,7 +176,6 @@ ynh_backup_if_checksum_is_different --file="$final_path/lib/config.local.php" cp "../conf/config.local.php" "$final_path/lib/config.local.php" # Set and save upload password, allowing an empty one -ynh_print_OFF if [ -z "$upload_password" ] then ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" @@ -187,14 +184,11 @@ else ynh_replace_special_string --match_string="__UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile" ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password" fi -ynh_print_ON #================================================= # CONFIGURE JIRAFEAU #================================================= -ynh_script_progression --message="Upgrading Jirafeau configuration..." --weight=2 - -var_root=/home/yunohost.app/$app +ynh_script_progression --message="Upgrading $app configuration..." --weight=2 ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile" if [ "$path_url" = "/" ] @@ -203,7 +197,7 @@ then else ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" fi -ynh_replace_string --match_string="__VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile" +ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$jirafeauconfigfile" ynh_replace_string --match_string="__ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile" # Recalculate and store the checksum of the file for the next upgrade. @@ -218,18 +212,8 @@ ynh_secure_remove --file=$final_path/install.php ynh_script_progression --message="Configuring the cron file..." --weight=1 ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" - -#================================================= -# GENERIC FINALISATION -#================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -chown -R root: $final_path - -mkdir -p $var_root/{files,links,async,block} -chown -R $app:root $var_root -chmod -R 700 $var_root +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # SETUP SSOWAT @@ -256,4 +240,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Jirafeau completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last