From ba463eea4b194eec4ed29e42669d2c6e85143306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 17 Apr 2021 15:47:43 +0200 Subject: [PATCH 1/5] install in sub dir --- README.md | 4 ---- README_fr.md | 6 +----- check_process | 3 ++- conf/nginx.conf | 1 + manifest.json | 10 ++++++++++ scripts/install | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b523625..35adc77 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,6 @@ How to configure this app: LDAP is not supported (blocked until Gotify core upstream implements it). -## Limitations - - * Require dedicated domain like `gotify.domain.tld` - ## Links * Report a bug: https://github.com/YunoHost-Apps/gotify_ynh/issues diff --git a/README_fr.md b/README_fr.md index b301310..46b757f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Gotify est un serveur simple permettant d'envoyer et de recevoir des messages via websocket. -**Version incluse :** 2.0.20 +**Version incluse :** 2.0.22 ## Captures d'écran @@ -31,10 +31,6 @@ Pour configurer Gotify : Pas de support de LDAP (non implémenté upstream) -## Limitations - - * Nécessite un domaine dédié comme par exemple `gotify.domain.tld` - ## Liens * Signaler un bug : https://github.com/YunoHost-Apps/gotify_ynh/issues diff --git a/check_process b/check_process index 96906bb..35e23d0 100644 --- a/check_process +++ b/check_process @@ -6,12 +6,13 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) + path="/path" (PATH) admin="john" (USER) password="pass" port="666" (PORT) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 486711d..4963313 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -18,6 +18,7 @@ location __PATH__/stream { location __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; + #sub_path_only rewrite ^/__PATH__(/.*) $1 break; proxy_set_header Host $host; proxy_buffering off; fastcgi_param REMOTE_USER $remote_user; diff --git a/manifest.json b/manifest.json index de61340..51416c8 100644 --- a/manifest.json +++ b/manifest.json @@ -32,6 +32,16 @@ }, "example": "example.com" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Gotify", + "fr": "Choisissez un chemin pour Gotify" + }, + "example": "/gotify", + "default": "/gotify" + }, { "name": "admin", "type": "user", diff --git a/scripts/install b/scripts/install index fff7f5f..b016ecb 100755 --- a/scripts/install +++ b/scripts/install @@ -21,7 +21,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=/ +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=1 password=$YNH_APP_ARG_PASSWORD From e6353b88c76fd38ccdb53f2db1be14f1d4f777c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 17 Apr 2021 15:48:48 +0200 Subject: [PATCH 2/5] add change url --- check_process | 2 +- scripts/change_url | 128 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 scripts/change_url diff --git a/check_process b/check_process index 35e23d0..ea87313 100644 --- a/check_process +++ b/check_process @@ -22,7 +22,7 @@ backup_restore=1 multi_instance=1 port_already_use=1 - change_url=0 + change_url=1 ;;; Upgrade options ; commit=e0fbbb9a6d2fd87b4d42e85c0fc8f4e479689abc name=Mon Feb 18 21:55:49 2019 +0100 Merge branch 'master' of github.com:YunoHost-Apps/gotify_ynh diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..2378050 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,128 @@ +#!/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 + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get $app port) + +#================================================= +# BACKUP BEFORE CHANGE URL 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" + +#================================================= +# 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" + +#================================================= +# 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 \ No newline at end of file From 41e49003c42d4ce33bdd31c5e0eba259d464fede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 17 Apr 2021 15:49:12 +0200 Subject: [PATCH 3/5] add pull request template --- 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..66608e8 --- /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/freshrss_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/freshrss_ynh%20PR-NUM-%20(USERNAME)/) From 39a6bdb6c5ad9d44fa416dd0298152128434500e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 17 Apr 2021 15:53:53 +0200 Subject: [PATCH 4/5] fix bad copy/paste --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index 66608e8..af09e6d 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -15,4 +15,4 @@ --- *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/freshrss_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/freshrss_ynh%20PR-NUM-%20(USERNAME)/) +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/gotify_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/gotify_ynh%20PR-NUM-%20(USERNAME)/) From 2bd8f4fafe55be9226e367dbe611a11131ba5c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 17 Apr 2021 16:08:58 +0200 Subject: [PATCH 5/5] update package version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 51416c8..b19baa6 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A simple server for sending and receiving messages.", "fr": "Un simple serveur pour envoyer et recevoir des messages." }, - "version": "2.0.22~ynh1", + "version": "2.0.22~ynh2", "url": "http://gotify.net", "license": "MIT", "maintainer": {