1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jirafeau_ynh.git synced 2024-09-03 19:35:53 +02:00

Add rights (#90)

This commit is contained in:
Éric Gaspar 2021-11-04 20:15:49 +01:00 committed by GitHub
parent bdc4f95f33
commit 8275615365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 187 additions and 181 deletions

View file

@ -1,3 +1,8 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Jirafeau for YunoHost # 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) [![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)* *[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install Jirafeau quickly and simply on a YunoHost server. > *This package allows 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## 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~ynh2
**Demo:** https://demo.yunohost.org/jirafeau/
## Screenshots ## Screenshots
![](http://i.imgur.com/TPjh48P.png) ![](./doc/screenshots/TPjh48P.png)
## Demo ## Disclaimers / important information
* [YunoHost demo](https://demo.yunohost.org/jirafeau/)
## Configuration ## Configuration
## Documentation ### Changing the conditions of use of the service
* Official documentation: 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 documentation: https://yunohost.org/en/app_jirafeau
## 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/) * Official app website: https://gitlab.com/mojo42/Jirafeau
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps-arm.yunohost.org/ci/apps/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 Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing).
## 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).
To try the testing branch, please proceed like that. 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 or
sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug 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

View file

@ -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) [![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) [![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.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble ## 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~ynh2
**Démo :** https://demo.yunohost.org/jirafeau/
## Captures d'écran ## Captures d'écran
![](http://i.imgur.com/TPjh48P.png) ![](./doc/screenshots/TPjh48P.png)
## Démo ## Avertissements / informations importantes
* [Démo officielle](https://demo.yunohost.org/jirafeau/)
## Configuration ## Configuration
## Documentation ### Changer les conditions d'utilisation du service
* Documentation officielle : 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`.
* Documentation YunoHost : https://yunohost.org/fr/app_jirafeau
## 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/) * Site officiel de l'app : https://gitlab.com/mojo42/Jirafeau
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau.svg)](https://ci-apps-arm.yunohost.org/ci/apps/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
## Limitations * Signaler un bug : https://github.com/YunoHost-Apps/jirafeau_ynh/issues
## 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/
---
## Informations pour les développeurs ## Informations pour les développeurs
@ -59,3 +50,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/jirafeau_ynh/tree/tes
ou ou
sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug 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

View file

@ -31,7 +31,7 @@ $cfg['web_root'] = 'https://' . '__DOMAIN__' . '__PATH__' . '/';
/* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264« /* 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. /* 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 * The mode »auto« will cause the script to detect the user's browser information

1
doc/DESCRIPTION.md Normal file
View file

@ -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.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -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.

9
doc/DISCLAIMER.md Normal file
View file

@ -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`.

9
doc/DISCLAIMER_fr.md Normal file
View file

@ -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`.

BIN
doc/screenshots/TPjh48P.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -8,13 +8,19 @@
}, },
"version": "4.3.0~ynh2", "version": "4.3.0~ynh2",
"url": "https://gitlab.com/mojo42/Jirafeau", "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", "license": "AGPL-3.0-only",
"maintainer": { "maintainer": {
"name": "julien", "name": "julien",
"email": "julien.malik@paraiso.me" "email": "julien.malik@paraiso.me"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.7" "yunohost": ">= 4.2.4"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -25,8 +31,7 @@
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
@ -40,18 +45,16 @@
"ask": { "ask": {
"en": "Choose an admin user (will be able to access admin.php page)", "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)" "fr": "Choisissez l'administrateur (seul autorisé à accéder à la page admin.php)"
}, }
"example": "johndoe"
}, },
{ {
"name": "upload_password", "name": "upload_password",
"type": "password", "type": "password",
"optional": true, "optional": true,
"ask": { "ask": {
"en": "Set the password granting upload permissions (leave empty to allow anybody to upload)", "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)" "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..."
}, }
"example": "supersecretpassword"
}, },
{ {
"name": "is_public", "name": "is_public",

View file

@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) 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 # DECLARE DATA AND CONF FILES TO BACKUP
@ -40,7 +41,7 @@ ynh_backup --src_path="$final_path"
# BACKUP OF THE DATA DIR # 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 # BACKUP OF THE NGINX CONFIGURATION

View file

@ -23,9 +23,7 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin_user=$YNH_APP_ARG_ADMIN_USER admin_user=$YNH_APP_ARG_ADMIN_USER
ynh_print_OFF
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
ynh_print_ON
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME 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=admin --value=$admin_user
ynh_app_setting_set --app=$app --key=is_public --value=$is_public 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 # 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" 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 # NGINX CONFIGURATION
#================================================= #=================================================
@ -70,14 +80,6 @@ ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_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 # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -97,7 +99,6 @@ jirafeauconfigfile="$final_path/lib/config.local.php"
cp "../conf/config.local.php" "$jirafeauconfigfile" cp "../conf/config.local.php" "$jirafeauconfigfile"
# Set and save upload password, allowing an empty one # Set and save upload password, allowing an empty one
ynh_print_OFF
if [ -z "$upload_password" ] if [ -z "$upload_password" ]
then then
ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" 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_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" ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
fi 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 # CONFIGURE JIRAFEAU
#================================================= #=================================================
ynh_script_progression --message="Configuring Jirafeau..." --weight=2 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" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
if [ "$path_url" = "/" ] if [ "$path_url" = "/" ]
then then
@ -122,7 +134,7 @@ then
else else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile"
fi 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" 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 # 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 # Remove the install.php
ynh_secure_remove --file=$final_path/install.php ynh_secure_remove --file=$final_path/install.php
chmod 400 "$jirafeauconfigfile"
chown $app:$app "$jirafeauconfigfile"
#================================================= #=================================================
# SET THE CRON FILE # SET THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Configuring the cron file..." --weight=2 ynh_script_progression --message="Configuring the cron file..." --weight=2
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
#================================================= chmod 644 "/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
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -18,13 +18,14 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE THE MAIN DIR OF THE APP # 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 # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -59,7 +60,7 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
ynh_script_progression --message="Removing data directory..." --weight=1 ynh_script_progression --message="Removing data directory..." --weight=1
ynh_secure_remove --file="/home/yunohost.app/$app" ynh_secure_remove --file="$datadir"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -75,4 +76,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of Jirafeau completed" --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -26,6 +26,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) 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 # CHECK IF THE APP CAN BE RESTORED
@ -40,27 +41,46 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" 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 # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing) # 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 # 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" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
@ -72,26 +92,8 @@ ynh_add_fpm_config
ynh_script_progression --message="Restoring the cron file..." --weight=1 ynh_script_progression --message="Restoring the cron file..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
#================================================= chmod 644 "/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
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -107,4 +109,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for Jirafeau" --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -21,10 +21,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin_user=$(ynh_app_setting_get --app=$app --key=admin) admin_user=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) 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) upload_password=$(ynh_app_setting_get --app=$app --key=upload_password)
ynh_print_ON
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -32,26 +31,37 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
upgrade_type=$(ynh_check_app_version_changed) 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 # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 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 final_path doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z "$final_path" ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi 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 # Migrate files from 3.4.1 to 4.1.1
current_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")" current_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")"
update_version="$(ynh_app_upstream_version)" update_version="$(ynh_app_upstream_version)"
@ -60,8 +70,6 @@ if [ ${current_version:0:1} -le 3 ] && [ ${update_version:0:1} -ge 4 ]
then then
ynh_script_progression --message="Migrating files..." --weight=5 ynh_script_progression --message="Migrating files..." --weight=5
var_root=/home/yunohost.app/$app
# Migrate files and links to the new directory structure # Migrate files and links to the new directory structure
for type in files links for type in files links
do do
@ -78,7 +86,7 @@ then
# Split the file name every 8 characters # Split the file name every 8 characters
split=0 split=0
full_path="$var_root/$type" full_path="$datadir/$type"
while [ $split -le ${#file} ] while [ $split -le ${#file} ]
do do
part_dir="${file:$split:8}" part_dir="${file:$split:8}"
@ -94,7 +102,7 @@ then
if [ "$type" = "files" ]; then if [ "$type" = "files" ]; then
mv "${full_file}_count" "$full_path" mv "${full_file}_count" "$full_path"
fi 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 done
# And clean the old directories # And clean the old directories
@ -109,23 +117,17 @@ then
then then
ynh_secure_remove --file="$file" ynh_secure_remove --file="$file"
fi 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 done
fi 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 # Create a dedicated user (if not existing)
ynh_backup_before_upgrade ynh_system_user_create --username=$app --home_dir="$final_path"
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
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -141,6 +143,10 @@ then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -149,14 +155,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_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 # 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" cp "../conf/config.local.php" "$final_path/lib/config.local.php"
# Set and save upload password, allowing an empty one # Set and save upload password, allowing an empty one
ynh_print_OFF
if [ -z "$upload_password" ] if [ -z "$upload_password" ]
then then
ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" 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_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" ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
fi fi
ynh_print_ON
#================================================= #=================================================
# CONFIGURE JIRAFEAU # CONFIGURE JIRAFEAU
#================================================= #=================================================
ynh_script_progression --message="Upgrading Jirafeau configuration..." --weight=2 ynh_script_progression --message="Upgrading $app configuration..." --weight=2
var_root=/home/yunohost.app/$app
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
if [ "$path_url" = "/" ] if [ "$path_url" = "/" ]
@ -203,7 +197,7 @@ then
else else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile"
fi 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" 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. # 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_script_progression --message="Configuring the cron file..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
#================================================= chmod 644 "/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
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -256,4 +240,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of Jirafeau completed" --last ynh_script_progression --message="Upgrade of $app completed" --last