From 98bf3a82e7db08cb78e2ab053f55bac10e23b1f1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 20:25:49 +0100 Subject: [PATCH 01/15] Activate sub_dir --- manifest.json | 10 ++++++++++ scripts/install | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 78b34d9..49777fb 100644 --- a/manifest.json +++ b/manifest.json @@ -30,6 +30,16 @@ }, "example": "distbin.example.com" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for distbin", + "fr": "Choisissez un chemin pour distbin" + }, + "example": "/distbin", + "default": "/distbin" + }, { "name": "is_public", "type": "boolean", diff --git a/scripts/install b/scripts/install index 9d4400f..53c6e8f 100644 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,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=$YNH_APP_ARG_IS_PUBLIC #language=$YNH_APP_ARG_LANGUAGE From d4d9d1eb70eb73268ab24d3171549f005af8d988 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 19:29:22 +0100 Subject: [PATCH 02/15] Update check_process --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 215ffde..25f5c73 100644 --- a/check_process +++ b/check_process @@ -9,7 +9,7 @@ is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=1 @@ -20,7 +20,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto From 27dae7d92fce7c496105866335857db647ec1b0f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 20:22:30 +0100 Subject: [PATCH 03/15] Fix subpath --- conf/.env | 2 +- conf/nginx.conf | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/conf/.env b/conf/.env index a5c103e..7d7f328 100644 --- a/conf/.env +++ b/conf/.env @@ -8,7 +8,7 @@ PORT=__PORT__ DB_DIR=__FINALPATH__/distbin-db # The external URL -EXTERNAL_URL=https://__DOMAIN_URI__ +EXTERNAL_URL=https://__DOMAIN_URI__/ # The internal URL INTERNAL_URL=http://localhost:__PORT__/ diff --git a/conf/nginx.conf b/conf/nginx.conf index 7cf6397..625b100 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,9 +6,14 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } + rewrite ^/distbin/(.*) /$1 break; proxy_pass http://127.0.0.1:__PORT__/; - proxy_set_header Host $host; - # proxy_buffering off; + proxy_pass_request_headers on; + proxy_redirect ~^/(.*) $scheme://$http_host/distbin/$1; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; From a876247fc54899070de9cc2f5c254af219ad3423 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 20:49:04 +0100 Subject: [PATCH 04/15] Update nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 625b100..03ae5c8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,7 +6,7 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - rewrite ^/distbin/(.*) /$1 break; + #rewrite ^/distbin/(.*) /$1 break; proxy_pass http://127.0.0.1:__PORT__/; proxy_pass_request_headers on; proxy_redirect ~^/(.*) $scheme://$http_host/distbin/$1; From 4f482e889e9c6241c9289a072ad3ca3f8b6b1204 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 22:01:09 +0100 Subject: [PATCH 05/15] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0150904..f45cc25 100644 --- a/scripts/install +++ b/scripts/install @@ -281,7 +281,7 @@ systemctl reload nginx # START SERVICE #================================================= -ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service" +ynh_systemd_action --action=start --service_name=$app --line_match="http" #================================================= # END OF SCRIPT From f7ba5671ed6e6c1a452afe7e991d2a9f4e242a21 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 22:13:19 +0100 Subject: [PATCH 06/15] Update change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 3d678fc..562dfe7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -17,7 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN -new_path="/" +new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME From 0a51abadd951800bcf13e11e39a2cc53835cbc6d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 22:18:29 +0100 Subject: [PATCH 07/15] Update check_process --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index 25f5c73..89b0b69 100644 --- a/check_process +++ b/check_process @@ -6,6 +6,7 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 From ebeb2d8933677d9e6c5d615c675fa82b153d9905 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:07:58 +0100 Subject: [PATCH 08/15] add port for change URL --- scripts/change_url | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/change_url b/scripts/change_url index 562dfe7..1986103 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get $app final_path) # Add settings here as needed by your application #db_name=$(ynh_app_setting_get "$app" db_name) #db_pwd=$(ynh_app_setting_get $app db_pwd) +port=$(ynh_app_setting_get $app port) #================================================= # CHECK THE SYNTAX OF THE PATHS From dda280bc062a7ca0c36c2a20dfe0b3d7a419940c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:13:47 +0100 Subject: [PATCH 09/15] Fix PATH --- conf/nginx.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 03ae5c8..677303b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,10 +6,9 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - #rewrite ^/distbin/(.*) /$1 break; proxy_pass http://127.0.0.1:__PORT__/; proxy_pass_request_headers on; - proxy_redirect ~^/(.*) $scheme://$http_host/distbin/$1; + proxy_redirect ~^/(.*) $scheme://$http_host__PATH__/$1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 86c722e03ec0471e4af0f7abe69bf5fff07168ac Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:29:35 +0100 Subject: [PATCH 10/15] Fix domain uri ending / --- scripts/change_url | 11 +++++++++-- scripts/install | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1986103..89fee3d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -103,7 +103,15 @@ ynh_systemd_action --action=stop --service_name=$app #================================================= # Change the URL in the configuration file -ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain$new_path" "$final_path/.env" + +if [ "$new_path" = "/" ] +then + new_domain_uri="$domain$path_url" +else + new_domain_uri="$domain" +fi + +ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain_uri/" "$final_path/.env" ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. @@ -117,7 +125,6 @@ ynh_store_file_checksum "$final_path/.env" ynh_systemd_action --action=start --service_name=$app - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index f45cc25..e5210b7 100644 --- a/scripts/install +++ b/scripts/install @@ -196,10 +196,16 @@ ynh_add_systemd_config ### (It's compatible with sed regular expressions syntax) cp "../conf/.env" "$final_path/.env" +if [ "$path_url" = "/" ] +then + domain_uri="$domain" +else + domain_uri="$domain$path_url" +fi ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env" ynh_replace_string "__PORT__" "$port" "$final_path/.env" -ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env" +ynh_replace_string "__DOMAIN_URI__" "$domain_uri" "$final_path/.env" ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/.env" #================================================= From e11b2e97951310d571c15bfd0fcbbecd9703b25b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:36:01 +0100 Subject: [PATCH 11/15] fix change url --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 89fee3d..e81bca0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -106,9 +106,9 @@ ynh_systemd_action --action=stop --service_name=$app if [ "$new_path" = "/" ] then - new_domain_uri="$domain$path_url" + new_domain_uri="$new_domain$new_path" else - new_domain_uri="$domain" + new_domain_uri="$new_domain" fi ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain_uri/" "$final_path/.env" From 382767ba91016249dc1415c28c6a919d110b35d7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:41:35 +0100 Subject: [PATCH 12/15] Fix == --- scripts/change_url | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e81bca0..ce2841f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -104,7 +104,7 @@ ynh_systemd_action --action=stop --service_name=$app # Change the URL in the configuration file -if [ "$new_path" = "/" ] +if [ "$new_path" == "/" ] then new_domain_uri="$new_domain$new_path" else diff --git a/scripts/install b/scripts/install index e5210b7..9eca9b9 100644 --- a/scripts/install +++ b/scripts/install @@ -196,7 +196,7 @@ ynh_add_systemd_config ### (It's compatible with sed regular expressions syntax) cp "../conf/.env" "$final_path/.env" -if [ "$path_url" = "/" ] +if [ "$path_url" == "/" ] then domain_uri="$domain" else From 83f1bc30c952dc8658c9ea478c60d7b4b109b2a0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:45:23 +0100 Subject: [PATCH 13/15] fix change_url --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ce2841f..f28efe9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -106,9 +106,9 @@ ynh_systemd_action --action=stop --service_name=$app if [ "$new_path" == "/" ] then - new_domain_uri="$new_domain$new_path" -else new_domain_uri="$new_domain" +else + new_domain_uri="$new_domain$new_path" fi ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain_uri/" "$final_path/.env" From 5e3931c7c383158c53c655640fae73dafc83a57f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:55:59 +0100 Subject: [PATCH 14/15] adding helper --- scripts/change_url | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f28efe9..afe76c7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -96,7 +97,7 @@ fi # STOP SERVICE #================================================= -ynh_systemd_action --action=stop --service_name=$app +ynh_systemd_action --action=stop --service_name=$app --log_path=systemd --line_match="Stopped Distbin Service" #================================================= # MODIFY A CONFIG FILE @@ -123,7 +124,7 @@ ynh_store_file_checksum "$final_path/.env" # START SERVICE #================================================= -ynh_systemd_action --action=start --service_name=$app +ynh_systemd_action --action=start --service_name=$app --line_match="http" #================================================= # GENERIC FINALISATION From 045a93f73711ae3a71c7bf7297f5e90f737c6e22 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 01:05:28 +0100 Subject: [PATCH 15/15] Remove upgrade from_commit --- check_process | 1 - 1 file changed, 1 deletion(-) diff --git a/check_process b/check_process index 89b0b69..9c48450 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,6 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=d39e8118603e1cc7e00d1c414ad9b55da68bfc7a backup_restore=1 multi_instance=1 incorrect_path=1