diff --git a/README.md b/README.md index 348fcf8..0d368ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # h5ai for 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) -[![Install h5ai with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=h5ai) +[![Install h5ai with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=h5ai) *[Lire ce readme en français.](./README_fr.md)* diff --git a/check_process b/check_process index 5f4a9a1..8bb191c 100644 --- a/check_process +++ b/check_process @@ -18,9 +18,7 @@ multi_instance=0 incorrect_path=1 port_already_use=0 - change_url=0 -;;; Levels - Level 5=auto + change_url=1 ;;; Options Email=alex.aubin@mailoo.org Notification=down diff --git a/conf/app.src b/conf/app.src index 8b6d764..290b95b 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=612acd8cc724ab42c5266f7b9966a0212b561331d8770b5609891edb5cb69a8b SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=h5ai-0.29.2.zip \ No newline at end of file +SOURCE_FILENAME=h5ai-0.29.2.zip diff --git a/manifest.json b/manifest.json index 7728111..411d33f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,12 @@ { - "name": "H5AI", + "name": "h5ai", "id": "h5ai", "packaging_format": 1, "description": { - "en": "A modern HTTP web server index for NGINX.", - "fr": "Un serveur moderne d'index pour NGINX." + "en": "Modern HTTP web server index for NGINX.", + "fr": "Serveur moderne d'index pour NGINX." }, - "version": "0.29.2~ynh2", + "version": "0.29.2~ynh3", "url": "https://larsjung.de/h5ai/", "license": "MIT", "maintainer": { @@ -14,7 +14,7 @@ "email": "alex.aubin@mailoo.org" }, "requirements": { - "yunohost": ">= 3.7.0" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ @@ -53,4 +53,4 @@ } ] } -} \ No newline at end of file +} diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..9eefc77 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## 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 +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/h5ai_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/h5ai_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..92e6311 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,106 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # 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 WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# GENERIC FINALISATION +#================================================= +# 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="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index d2d49b8..58be67e 100644 --- a/scripts/install +++ b/scripts/install @@ -25,19 +25,19 @@ is_public=$YNH_APP_ARG_IS_PUBLIC 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 - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 +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 + # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -60,15 +60,6 @@ ynh_script_progression --message="Setting up source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Restore permissions on app files -chown -R www-data:www-data "$final_path" - #================================================= # NGINX CONFIGURATION #================================================= @@ -77,6 +68,23 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Restore permissions on app files +chown -R $app: "$final_path" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index de6c4b0..09f0850 100644 --- a/scripts/remove +++ b/scripts/remove @@ -26,6 +26,14 @@ ynh_script_progression --message="Removing $app main directory..." --weight=3 # Remove sources ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 6371596..4a4e6cb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -51,12 +51,20 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files -chown -R www-data:www-data "$final_path" +chown -R $app: "$final_path" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index afb6b80..366ff9d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,12 +67,6 @@ ynh_clean_setup () { # 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 #================================================= @@ -90,9 +84,17 @@ fi #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 -# Create a dedicated nginx config +# 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 + #================================================= # GENERIC FINALIZATION #================================================= @@ -100,7 +102,7 @@ ynh_add_nginx_config #================================================= # Set permissions on app files -chown -R www-data:www-data "$final_path" +chown -R $app: "$final_path" #================================================= # RELOAD NGINX