From 98bf3a82e7db08cb78e2ab053f55bac10e23b1f1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 20:25:49 +0100 Subject: [PATCH 01/18] 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 acb8124b7d0003e7939307b4afdb758fb1705f1e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 Mar 2019 20:31:45 +0100 Subject: [PATCH 02/18] Upgrade to 1.2.0 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/install | 7 ++++--- scripts/restore | 2 +- scripts/upgrade | 9 +++------ 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b57ca08..4d9a355 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A distributed pastebin. i.e. it is a service where anyone can post things on the A networked place to store posted web documents. This is meant to allow for distributed social commentary and reaction around these documents using best practices recommended or noted by the W3C Social Web Working Group. -**Shipped version:** 1.0 +**Shipped version:** 1.2.0 ## Screenshots diff --git a/conf/app.src b/conf/app.src index e4dd89f..5334061 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=url of app's source -SOURCE_SUM=sha256 checksum +SOURCE_URL=https://github.com/gobengo/distbin/archive/v1.2.0.tar.gz +SOURCE_SUM=ae72d386e9c68afa4d6b08f0a9c9b441a04176001beb226b903f924076e5cfcb SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index ec088fa..e2d1084 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Distributed pastebin with ActivityPub.", "fr": "Pastebin distribué utilisant le protocole ActivityPub." }, - "version": "1.0~ynh6", + "version": "1.2.0~ynh1", "url": "https://example.com", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 035ba43..979013d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="ca-certificates" +pkg_dependencies="ca-certificates curl sudo" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index bf1b486..93763f3 100644 --- a/scripts/install +++ b/scripts/install @@ -102,7 +102,7 @@ ynh_print_info "Installing dependencies ..." ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs 8 +ynh_install_nodejs 10 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -115,8 +115,7 @@ ynh_print_info "Setting up source files ..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src -#ynh_setup_source "$final_path" -git clone https://github.com/gobengo/distbin "$final_path" +ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION @@ -150,6 +149,8 @@ chown -R "$app":"$app" "/var/log/$app" #================================================= mkdir -p "$final_path/distbin-db" +mkdir -p "$final_path/distbin-db/activities" +mkdir -p "$final_path/distbin-db/inbox" #================================================= # MAKE SETUP diff --git a/scripts/restore b/scripts/restore index e3e21d9..4196bee 100644 --- a/scripts/restore +++ b/scripts/restore @@ -90,7 +90,7 @@ ynh_print_info "Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs 8 +ynh_install_nodejs 10 #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index b5a2756..1ad8b02 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -82,11 +82,7 @@ ynh_systemd_action --action=stop --service_name=$app ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src# -#ynh_setup_source "$final_path" - -git clone --quiet https://github.com/gobengo/distbin "$final_path/upgrade" -cp -a "$final_path/upgrade/." "$final_path/." -rm -r "$final_path/upgrade" +ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION @@ -102,7 +98,8 @@ ynh_add_nginx_config ynh_print_info "Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs 8 +ynh_remove_nodejs +ynh_install_nodejs 10 #================================================= # CREATE DEDICATED USER From 2ea449581639a346090b9b45e7ceb90f57a3bd69 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 19:17:19 +0100 Subject: [PATCH 03/18] Add internal URL --- conf/.env | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/.env b/conf/.env index 1453925..a5c103e 100644 --- a/conf/.env +++ b/conf/.env @@ -10,5 +10,8 @@ DB_DIR=__FINALPATH__/distbin-db # The external URL EXTERNAL_URL=https://__DOMAIN_URI__ +# The internal URL +INTERNAL_URL=http://localhost:__PORT__/ + # The Node Environnement NODE_ENV=production \ No newline at end of file From 5c6fdf26e14c2daee78ba646b7975425696f91f7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 19:22:35 +0100 Subject: [PATCH 04/18] Fix service start --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 93763f3..e34eb10 100644 --- a/scripts/install +++ b/scripts/install @@ -281,7 +281,7 @@ systemctl reload nginx # START SERVICE #================================================= -ynh_systemd_action --action=start --service_name=$app --line_match="http://localhost:" +ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service" #================================================= # END OF SCRIPT From d4d9d1eb70eb73268ab24d3171549f005af8d988 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 19:29:22 +0100 Subject: [PATCH 05/18] 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 06/18] 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 07/18] 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 08/18] 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 09/18] 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 10/18] 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 11/18] 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 12/18] 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 13/18] 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 14/18] 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 15/18] 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 16/18] 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 17/18] 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 18/18] 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