From 95f1d87cdee7e0c8d7c46465ec94622b6c0b5eeb Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 2 Dec 2020 12:13:13 +0100 Subject: [PATCH 01/12] Add user --- check_process | 2 -- conf/app.src | 2 +- manifest.json | 10 +++++----- scripts/install | 26 +++++++++++++++++--------- scripts/remove | 8 ++++++++ scripts/restore | 10 +++++++++- scripts/upgrade | 12 ++++++++++-- 7 files changed, 50 insertions(+), 20 deletions(-) diff --git a/check_process b/check_process index 5f4a9a1..17fe16f 100644 --- a/check_process +++ b/check_process @@ -19,8 +19,6 @@ incorrect_path=1 port_already_use=0 change_url=0 -;;; Levels - Level 5=auto ;;; 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..af7559e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { - "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", "url": "https://larsjung.de/h5ai/", @@ -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/scripts/install b/scripts/install index d2d49b8..7d30d96 100644 --- a/scripts/install +++ b/scripts/install @@ -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..6390aaf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,9 +90,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 +108,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 From 0c7a006f2ed99adcd413a8e94108572600e7897a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 08:13:43 +0100 Subject: [PATCH 02/12] Update upgrade --- scripts/upgrade | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6390aaf..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 #================================================= From 83aef6faf07cf2d2322aca6f24707b9cb2a5019e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 08:26:41 +0100 Subject: [PATCH 03/12] Create change_url --- scripts/change_url | 134 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 scripts/change_url diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..126010e --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,134 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +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..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --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 + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 + +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 + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last From 7b161c588d7dbfa2dbe9691c2c2c39b75c4392a5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 08:27:28 +0100 Subject: [PATCH 04/12] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 17fe16f..8bb191c 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ multi_instance=0 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=alex.aubin@mailoo.org Notification=down From 4103a4a4838cbc9ab8b27519809f52068e4cfbdd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 08:38:26 +0100 Subject: [PATCH 05/12] Update change_url --- scripts/change_url | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 126010e..c4fd29a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh source /usr/share/yunohost/helpers #================================================= From c6ee66ec54bbc82302e4bdfdcc8e4bdd65ddffbb Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 08:57:04 +0100 Subject: [PATCH 06/12] Update change_url --- scripts/change_url | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c4fd29a..2dacb1d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -112,13 +112,6 @@ fi #================================================= # GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # RELOAD NGINX #================================================= From 49114f16cf14948bbad2d9d8542ff092131fd7f2 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 09:10:22 +0100 Subject: [PATCH 07/12] Update change_url --- scripts/change_url | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 2dacb1d..6967d80 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -66,15 +66,6 @@ then change_path=1 fi -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # MODIFY URL IN NGINX CONF #================================================= From 036871daefffa7b6ac751961cd211c3aae00a4a5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 09:22:30 +0100 Subject: [PATCH 08/12] Fix --- scripts/change_url | 21 +++++---------------- scripts/install | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 6967d80..92e6311 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,20 +23,15 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +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) -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 +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 @@ -69,7 +64,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -95,18 +90,12 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -114,4 +103,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 7d30d96..5a4d15c 100644 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,7 @@ 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 + final_path=/var/www$path_url else final_path=/var/www/$app fi From efbcabaddb82ecc2b254628545c96c1a081a0cc1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 09:31:53 +0100 Subject: [PATCH 09/12] Update install --- scripts/install | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 5a4d15c..58be67e 100644 --- a/scripts/install +++ b/scripts/install @@ -25,6 +25,11 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME +#================================================= +# 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... @@ -33,11 +38,6 @@ 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 - # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url From 3a1c41cc49f4dbeebcd55e5b3a9d59781a138a49 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 09:35:20 +0100 Subject: [PATCH 10/12] Create pull_request_template.md --- pull_request_template.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pull_request_template.md 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)/) From dcf40386bbecd8ac0cf50e4f9441da82f9c05838 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:58:18 +0100 Subject: [PATCH 11/12] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index af7559e..411d33f 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "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": { From 939c49f1d0b029794181922712afea16cfee8092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 19 Dec 2020 23:00:14 +0100 Subject: [PATCH 12/12] Set badge in SVG --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)*