diff --git a/README.md b/README.md index f8d45cf..348fcf8 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,64 @@ -# H5AI for Yunohost +# h5ai for YunoHost -[H5AI](https://larsjung.de/h5ai/) is a modern file indexer for HTTP web servers. It allows to display and browse directories containing various documents with a clean and light interface. +[![Integration level](https://dash.yunohost.org/integration/h5ai.svg)](https://dash.yunohost.org/appci/app/h5ai) ![](https://ci-apps.yunohost.org/ci/badges/h5ai.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/h5ai.maintain.svg) +[![Install h5ai with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=h5ai) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install h5ai 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 +[h5ai](https://larsjung.de/h5ai/) is a modern file indexer for HTTP web servers. It allows to display and browse directories containing various documents with a clean and light interface. + +**Shipped version:** 0.29.2 Screenshot : ![](./doc/screenshot.jpg) -## Usage +## Configuration -After installing the application, you can add documents in `/var/www/documents` (or the corresponding path you choosed). +After installing the application, you can add documents in `/var/www/documents` (or the corresponding path you choosed). +h5ai doesn't allow to edit or upload new documents directly from the web browser. But you can imagine coupling the folder `/var/www/documents` to Nextcloud or some sort of FTP to allow some users to upload content, and use h5ai as a public read-only interface. +The main configuration file is `_h5ai/private/conf/options.json`. You might want to change some of the documented settings. But there are some more files in `_h5ai/private/conf` you might have a look at. -H5ai doesn't allow to edit or upload new documents directly from the web browser. But you can imagine coupling the folder `/var/www/documents` to nextcloud or some sort of FTP to allow some users to upload content, and use h5ai as a public read-only interface. +## Documentation + + * Official documentation: https://larsjung.de/h5ai/ + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/h5ai%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/h5ai/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/h5ai%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/h5ai/) + +## Limitations + +* Any known limitations. + +## Additional information + +* Other info you would like to add about this app. + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/h5ai_ynh/issues + * App website: https://larsjung.de/h5ai/ + * Upstream app repository: https://github.com/lrsjng/h5ai + * YunoHost website: https://yunohost.org/ + +--- + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing --debug +or +sudo yunohost app upgrade h5ai -u https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing --debug +``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..230355b --- /dev/null +++ b/README_fr.md @@ -0,0 +1,65 @@ +# h5ai pour YunoHost + +[![Integration level](https://dash.yunohost.org/integration/h5ai.svg)](https://dash.yunohost.org/appci/app/h5ai) ![](https://ci-apps.yunohost.org/ci/badges/h5ai.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/h5ai.maintain.svg) +[![Installer h5ai avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=h5ai) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer h5ai rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* + +## Vue d'ensemble +[h5ai](https://larsjung.de/h5ai/) est un indexeur de fichiers moderne pour les serveurs Web HTTP. Il permet d'afficher et de parcourir des répertoires contenant divers documents avec une interface légère et claire. + +**Version incluse :** 0.29.2 + +## Captures d'écran + +![](./doc/screenshot.jpg) + +## Configuration + +Après avoir installé l'application, vous pouvez ajouter des documents dans `/var/www/documents` (ou le chemin correspondant que vous avez choisi). +h5ai ne permet pas de modifier ou de télécharger de nouveaux documents directement à partir du navigateur Web. Vous pouvez imaginer coupler le dossier `/var/www/documents` à Nextcloud ou un FTP pour permettre à certains utilisateurs de télécharger du contenu et d'utiliser h5ai comme interface publique en lecture seule. +Le fichier de configuration principal est `_h5ai / private / conf / options.json`. Vous souhaiterez peut-être modifier certains des paramètres documentés. Mais il y a d'autres fichiers dans `_h5ai / private / conf` que vous pourriez consulter. + +## Documentation + + * Documentation officielle : https://larsjung.de/h5ai/ + * Documentation YunoHost : Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. + +## Caractéristiques spécifiques YunoHost + +#### Architectures supportées + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/h5ai%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/h5ai/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/h5ai%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/h5ai/) + +## Limitations + +* Limitations connues. + +## Informations additionnelles + +* Autres informations que vous souhaitez ajouter sur cette application. + +## Liens + + * Signaler un bug : https://github.com/YunoHost-Apps/h5ai_ynh/issues + * Site de l'application : https://larsjung.de/h5ai/ + * Dépôt de l'application principale : https://github.com/lrsjng/h5ai + * Site web YunoHost : https://yunohost.org/ + +--- + +## Informations pour les développeurs + + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing --debug +ou +sudo yunohost app upgrade h5ai -u https://github.com/YunoHost-Apps/h5ai_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index a557e1f..5f4a9a1 100644 --- a/check_process +++ b/check_process @@ -12,8 +12,9 @@ setup_nourl=0 setup_private=1 setup_public=1 - upgrade=0 - backup_restore=0 + upgrade=1 + upgrade=1 from_commit=73f74039fb63adc555222d73ded6b43a64d41456 + backup_restore=1 multi_instance=0 incorrect_path=1 port_already_use=0 @@ -23,3 +24,7 @@ ;;; Options Email=alex.aubin@mailoo.org Notification=down +;;; Upgrade options + ; commit=73f74039fb63adc555222d73ded6b43a64d41456 + name=Update check_process, 24 Jun 2019 + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/app.src b/conf/app.src index 4112d7d..8b6d764 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://release.larsjung.de/h5ai/h5ai-0.29.0.zip -SOURCE_SUM=508324f14df32bfa79096b8c272dd644cbd8ff97d0dbc7dde2eec6ce7d95104e +SOURCE_URL=https://release.larsjung.de/h5ai/h5ai-0.29.2.zip +SOURCE_SUM=612acd8cc724ab42c5266f7b9966a0212b561331d8770b5609891edb5cb69a8b SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=h5ai-0.29.0.zip +SOURCE_FILENAME=h5ai-0.29.2.zip \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index c7ecfa0..cdbdb21 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,6 +7,8 @@ location __PATH__/ { index index.php __PATH__/_h5ai/public/index.php; try_files $uri.html $uri $uri/ =404; + + proxy_pass_header Content-Type; client_max_body_size 10G; diff --git a/manifest.json b/manifest.json index fb945f0..36a85cf 100644 --- a/manifest.json +++ b/manifest.json @@ -2,10 +2,10 @@ "name": "H5AI", "id": "h5ai", "packaging_format": 1, - "version": "0.29.0~ynh1", + "version": "0.29.2~ynh1", "description": { - "en": "A modern HTTP web server index for Nginx.", - "fr": "Un serveur moderne d'index pour Nginx." + "en": "A modern HTTP web server index for NGINX.", + "fr": "Un serveur moderne d'index pour NGINX." }, "url": "https://larsjung.de/h5ai/", "license": "MIT", @@ -14,12 +14,12 @@ "email": "alex.aubin@mailoo.org" }, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.7.0" }, "multi_instance": false, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ @@ -27,8 +27,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for H5AI", - "fr": "Choisissez un domaine pour H5AI" + "en": "Choose a domain for h5ai", + "fr": "Choisissez un domaine pour h5ai" }, "example": "domain.org" }, @@ -36,8 +36,8 @@ "name": "path", "type": "path", "ask": { - "en": "Choose a path for H5AI", - "fr": "Choisissez un chemin pour H5AI" + "en": "Choose a path for h5ai", + "fr": "Choisissez un chemin pour h5ai" }, "example": "/documents", "default": "/documents" @@ -53,4 +53,4 @@ } ] } -} +} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..c45c6e1 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,49 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." + +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) + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" --is_big + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index e5c9550..d2d49b8 100644 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ fi ynh_script_progression --message="Validating installation parameters..." --weight=1 # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url # Check final_path availability test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -49,25 +49,30 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src -# For this app sources are in app subdirectory ynh_setup_source "$final_path" -# Set permissions to phpsysinfo directory -chown -R www-data: "$final_path" +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Restore permissions on app files +chown -R www-data:www-data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -80,15 +85,20 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission "main" --add "visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 9b37d5e..de6c4b0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,13 +14,14 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -final_path=$(ynh_app_setting_get "$app" final_path) + +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE THE MAIN DIR OF THE APP #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +ynh_script_progression --message="Removing $app main directory..." --weight=3 # Remove sources ynh_secure_remove --file="$final_path" @@ -28,9 +29,12 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 ynh_remove_nginx_config -systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..6371596 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,74 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# 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 " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=4 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R www-data:www-data "$final_path" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..afb6b80 --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,116 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME +if [[ "$path_url" != "/" ]] +then + # We use the path url name (e.g. /documents) instead of h5ai for convenience... + final_path=/var/www/$path_url +else + final_path=/var/www/$app +fi + +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# 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 + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --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 + +#================================================= +# CHECK THE PATH +#================================================= + +path_url=$(ynh_normalize_url_path --path_url=$path_url) + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=4 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R www-data:www-data "$final_path" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last