From fc5f7521f2cf3a6e7c4747e353131473f0bb1b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:16:11 +0100 Subject: [PATCH 1/9] v2 --- conf/nginx.conf | 2 +- manifest.toml | 60 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 10 ++++---- scripts/backup | 8 +++---- scripts/change_url | 38 ++++++++++++++--------------- scripts/install | 30 +++++++++++------------ scripts/remove | 10 ++++---- scripts/restore | 12 +++++----- scripts/upgrade | 22 ++++++++--------- 9 files changed, 126 insertions(+), 66 deletions(-) create mode 100644 manifest.toml diff --git a/conf/nginx.conf b/conf/nginx.conf index 8b49fab..efeb0e3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -18,7 +18,7 @@ location @__NAME__--proxy { # Support relative URLs __REDIRECT_BLOCK__ -location __PATH_URL_SLASH__ { +location __PATH_SLASH__ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..8d6ba9f --- /dev/null +++ b/manifest.toml @@ -0,0 +1,60 @@ +packaging_format = 2 + +id = "reverseproxy" +name = "Reverse Proxy" +description.en = "Create a reverse proxy to a socket/port, optionally serve static files from folder" +description.fr = "Créer un reverse proxy vers un socket/port, optionnellement servir des fichiers statiques depuis un dossier" + +version = "0.2~ynh1" + +maintainers = ["selfhoster1312"] + +[upstream] +website = "https://en.wikipedia.org/wiki/Reverse_proxy" +license = "AGPL-3.0-or-later" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.2" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + + [install.proxy_path] + ask.en = "Redirect destination path (unix:/file for socket)" + ask.fr = "Emplacement de destination (unix:/fichier pour socket)" + type = "string" + example = "http://127.0.0.1:8080" + + [install.init_main_permission] + type = "group" + default = false + + [install.assets_path] + ask.en = "Static assets folder" + ask.fr = "Dossier pour les fichiers statiques" + type = "string" + optional = true + example = "/opt/foo/www/" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index d5b7897..d96fb6a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -47,14 +47,14 @@ rp_validate_assets_path() { fi } -# When the app is not in the webroot (path_url = /), need to add a redirect block +# When the app is not in the webroot (path = /), need to add a redirect block # to app/ so relative URLs work rp_handle_webroot() { - if [[ "$path_url" = "/" ]]; then - path_url_slash="/" + if [[ "$path" = "/" ]]; then + path_slash="/" redirect_block="# Not needed for webroot" else - path_url_slash=""$path_url"/" - redirect_block="location = "$path_url" { return 302 "$path_url_slash"; }" + path_slash=""$path"/" + redirect_block="location = "$path" { return 302 "$path_slash"; }" fi } diff --git a/scripts/backup b/scripts/backup index 1b8acfc..614886b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,16 +14,16 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." # Retrieve arguments -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 9f8d871..1ef3181 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,17 +14,17 @@ source _common.sh #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -app=$YNH_APP_INSTANCE_NAME -old_domain=$YNH_APP_OLD_DOMAIN -new_domain=$YNH_APP_NEW_DOMAIN -old_path=$YNH_APP_OLD_PATH -new_path=$YNH_APP_NEW_PATH +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH +#REMOVEME? new_path=$YNH_APP_NEW_PATH # Path availability is already checked for @@ -34,11 +34,11 @@ new_path=$YNH_APP_NEW_PATH # Nginx configuration ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -path_url="$new_path" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +path="$new_path" domain="$old_domain" -proxy_path="$(ynh_app_setting_get --app=$app --key=proxy_path)" -assets_path="$(ynh_app_setting_get --app=$app --key=assets_path)" +#REMOVEME? proxy_path="$(ynh_app_setting_get --app=$app --key=proxy_path)" +#REMOVEME? assets_path="$(ynh_app_setting_get --app=$app --key=assets_path)" # Validate reverse proxy destination rp_validate_proxy_path @@ -46,20 +46,20 @@ rp_validate_proxy_path # Validate assets_path rp_validate_assets_path -# Special case for "/" path_url +# Special case for "/" path rp_handle_webroot -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -ynh_backup_if_checksum_is_different --file="$nginx_conf_path" -ynh_add_nginx_config +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" +#REMOVEME? ynh_add_nginx_config # Move file to new domain if domain has changed -if [[ "$old_domain" != "$new_domain" ]]; then - new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path $new_nginx_conf_path - ynh_store_file_checksum --file="$new_nginx_conf_path" +#REMOVEME? if [[ "$old_domain" != "$new_domain" ]]; then +#REMOVEME? new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path $new_nginx_conf_path +#REMOVEME? ynh_store_file_checksum --file="$new_nginx_conf_path" fi diff --git a/scripts/install b/scripts/install index da62af9..f9d017f 100644 --- a/scripts/install +++ b/scripts/install @@ -14,26 +14,26 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= # Retrieve arguments -app=$YNH_APP_INSTANCE_NAME -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -proxy_path=$YNH_APP_ARG_PROXY_PATH -assets_path=$YNH_APP_ARG_ASSETS_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? proxy_path=$YNH_APP_ARG_PROXY_PATH +#REMOVEME? assets_path=$YNH_APP_ARG_ASSETS_PATH +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC #================================================= # REVERSEPROXY_YNH #================================================= # Check domain/path availability -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path # Validate reverse proxy destination rp_validate_proxy_path @@ -41,22 +41,22 @@ rp_validate_proxy_path # Validate assets_path rp_validate_assets_path -# Special case for "/" path_url +# Special case for "/" path rp_handle_webroot # Save extra settings -ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path -ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path +#REMOVEME? ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path +#REMOVEME? ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path # Configure nginx ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) ynh_add_nginx_config # Make app public if necessary (yunohost setting boolean is 1 when true) -ynh_script_progression --message="Configuring permissions..." --weight=2 -if [ $is_public -eq 1 ]; then - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=2 +#REMOVEME? if [ $is_public -eq 1 ]; then +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 6a2cff8..999ff91 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,11 +12,11 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 # Retrieve arguments -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # REVERSEPROXY_YNH @@ -26,8 +26,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf # Reload nginx -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index a8bb89f..5399b61 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,18 +14,18 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= # Retrieve arguments -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) -assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) +#REMOVEME? assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) #================================================= # REVERSEPROXY_YNH diff --git a/scripts/upgrade b/scripts/upgrade index 2c21e32..9fa15a2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,24 +15,24 @@ source /usr/share/yunohost/helpers #================================================= # Retrieve arguments -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) -assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) +#REMOVEME? assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # REVERSEPROXY_YNH @@ -44,12 +44,12 @@ rp_validate_proxy_path # Validate assets_path rp_validate_assets_path -# Special case for "/" path_url +# Special case for "/" path rp_handle_webroot # Configure nginx ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) ynh_add_nginx_config #================================================= From 860ca9420277a81f4e871c59875aa779d5737ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:20:44 +0100 Subject: [PATCH 2/9] v2 --- check_process | 20 --------- doc/{DISCLAIMER.md => ADMIN.md} | 0 doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 0 manifest.json | 63 --------------------------- manifest.toml | 19 ++++---- scripts/backup | 18 +------- scripts/change_url | 20 --------- scripts/install | 34 +-------------- scripts/remove | 13 ------ scripts/restore | 18 -------- scripts/upgrade | 26 +---------- tests.toml | 7 +++ 12 files changed, 19 insertions(+), 219 deletions(-) delete mode 100644 check_process rename doc/{DISCLAIMER.md => ADMIN.md} (100%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (100%) delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 38d1606..0000000 --- a/check_process +++ /dev/null @@ -1,20 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - proxy_path="http://127.0.0.1:6787" - assets_path="/usr/share/yunohost/admin" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - change_url=1 -;;; Options -Email= -Notification=none diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index af517c9..0000000 --- a/manifest.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "Reverse Proxy", - "id": "reverseproxy", - "packaging_format": 1, - "description": { - "en": "Create a reverse proxy to a socket/port, optionally serve static files from folder", - "fr": "Créer un reverse proxy vers un socket/port, optionnellement servir des fichiers statiques depuis un dossier" - }, - "version": "0.2~ynh1", - "license": "AGPL-3.0-or-later", - "url": "https://en.wikipedia.org/wiki/Reverse_proxy", - "upstream": { - "website": "https://en.wikipedia.org/wiki/Reverse_proxy" - }, - "maintainer": { - "name": "selfhoster1312", - "email": "selfhoster1312@kl.netlib.re" - }, - "requirements": { - "yunohost": ">= 11.2" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/proxy" - }, - { - "name": "proxy_path", - "type": "string", - "ask": { - "en": "Redirect destination path (unix:/file for socket)", - "fr": "Emplacement de destination (unix:/fichier pour socket)" - }, - "example": "http://127.0.0.1:8080" - }, - { - "name": "is_public", - "type": "boolean", - "default": false - }, - { - "name": "assets_path", - "type": "string", - "ask": { - "en": "Static assets folder", - "fr": "Dossier pour les fichiers statiques" - }, - "optional": true, - "example": "/opt/foo/www/" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 8d6ba9f..40f38b6 100644 --- a/manifest.toml +++ b/manifest.toml @@ -10,28 +10,27 @@ version = "0.2~ynh1" maintainers = ["selfhoster1312"] [upstream] -website = "https://en.wikipedia.org/wiki/Reverse_proxy" license = "AGPL-3.0-or-later" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. +website = "https://en.wikipedia.org/wiki/Reverse_proxy" [integration] yunohost = ">= 11.2" architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +ldap = "not_relevant" + +sso = "not_relevant" + +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" [install.proxy_path] diff --git a/scripts/backup b/scripts/backup index 614886b..3e94ec0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,28 +9,12 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -# Retrieve arguments -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= # Copy the conf files -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" +ynh_backup --src_path="/etc/nginx/conf.d/${domain}.d/${app}.conf" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 1ef3181..7083bf2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,26 +8,6 @@ source /usr/share/yunohost/helpers source _common.sh - -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -# Path availability is already checked for - #================================================= # REVERSEPROXY_YNH #================================================= diff --git a/scripts/install b/scripts/install index f9d017f..6b28dd2 100644 --- a/scripts/install +++ b/scripts/install @@ -9,32 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -# Retrieve arguments -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? proxy_path=$YNH_APP_ARG_PROXY_PATH -#REMOVEME? assets_path=$YNH_APP_ARG_ASSETS_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC - #================================================= # REVERSEPROXY_YNH #================================================= -# Check domain/path availability -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - # Validate reverse proxy destination rp_validate_proxy_path @@ -44,20 +22,10 @@ rp_validate_assets_path # Special case for "/" path rp_handle_webroot -# Save extra settings -#REMOVEME? ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path -#REMOVEME? ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path - # Configure nginx ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -ynh_add_nginx_config -# Make app public if necessary (yunohost setting boolean is 1 when true) -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=2 -#REMOVEME? if [ $is_public -eq 1 ]; then -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi +ynh_add_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 999ff91..984660f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,15 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -# Retrieve arguments -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # REVERSEPROXY_YNH #================================================= @@ -25,10 +16,6 @@ source /usr/share/yunohost/helpers # Remove configuration files ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf -# Reload nginx -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 5399b61..47cf284 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,24 +9,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= - -# Retrieve arguments -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) -#REMOVEME? assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) - #================================================= # REVERSEPROXY_YNH #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9fa15a2..3030cdc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,30 +10,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -# Retrieve arguments -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? proxy_path=$(ynh_app_setting_get --app=$app --key=proxy_path) -#REMOVEME? assets_path=$(ynh_app_setting_get --app=$app --key=assets_path) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # REVERSEPROXY_YNH #================================================= @@ -49,7 +25,7 @@ rp_handle_webroot # Configure nginx ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) + ynh_add_nginx_config #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..ec288a8 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + + args.proxy_path="http://127.0.0.1:6787" + args.assets_path="/usr/share/yunohost/admin" \ No newline at end of file From 2951e42d397cdae0104973e780a6ad87a3da6bd8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 25 Nov 2023 18:20:49 +0000 Subject: [PATCH 3/9] Auto-update README --- README.md | 14 -------------- README_fr.md | 14 -------------- 2 files changed, 28 deletions(-) diff --git a/README.md b/README.md index f9b5d55..ecfae0b 100644 --- a/README.md +++ b/README.md @@ -28,20 +28,6 @@ Please be aware that SSOWat sends user credentials in plaintext to the backend, **Shipped version:** 0.2~ynh1 -## Disclaimers / important information - -### Backend web path - -The request is transmitted as-is to the backend server. This usually means that the backend service shoudl be aware of the web path used to access the service. For example, if using the application is installed to `example.com/proxy`, your backend application should produce absolute links starting with `example.com/proxy/` too. - -To support relative URLs from the backend, accessing the application via `http(s)://example.com/proxy` will permanent redirect (302) to `http(s)://example.com/proxy/` (trailing slash). Otherwise, a relative link like `` would try to load `http(s)://example.com/style.css` which would fail. - -It is possible that your backend service does not support setting up a "base URL" (custom web path). In that case, you will have to install the application on a dedicated (sub)domain. - -### Plaintext localhost backend - -Plaintext HTTP backend is only allowed on localhost. For now, only 127.X.X.X is allowed. 10.X.X.X should also be supported. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 0580432..48da124 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,20 +28,6 @@ Attention, SSOWat envoie les identifiants des utilisateurices en clair jusqu'au **Version incluse :** 0.2~ynh1 -## Avertissements / informations importantes - -### Chemin web du backend - -La requête est transmise telle-quelle au serveur backend. Cela veut usuellement dire que le service backend doit avoir connaissance du chemin web utilisé pour accéder au service. Par exemple, si l'application est installée sur `example.com/proxy`, votre application backend devrait produire des liens absolus commençant par `example.com/proxy/`. - -Pour supporter les URLs relatives depuis le backend, accéder à l'application via `http(s)://example.com/proxy` produit une redirection permanente (302) vers `http(s)://example.com/proxy/` (avec le slash de fin). Sinon, un lien relatif comme `` essayerait de charger `http(s)://example.com/style.css`, ce qui échouerait. - -Il est possible que votre service backend ne supporte pas de configurer une "base URL" (chemin web personnalisé). Dans ce cas, il faudra installer l'application sur un (sous-)domaine dédié. - -### Backend localhost en clair (plaintext) - -Les connexions en clair en HTTP au backend ne sont autorisées qu'en localhost sur les adresses 127.X.X.X. Il faudrait aussi supporter 10.X.X.X. - ## Documentations et ressources * Site officiel de l’app : From ecfcf2d4e8dfd2f28baecf9b5821882b376837d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:23:56 +0100 Subject: [PATCH 4/9] v2 --- doc/ADMIN_fr.md | 4 ++-- scripts/change_url | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 4f4e535..fc2b9fb 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -1,8 +1,8 @@ ### Chemin web du backend -La requête est transmise telle-quelle au serveur backend. Cela veut usuellement dire que le service backend doit avoir connaissance du chemin web utilisé pour accéder au service. Par exemple, si l'application est installée sur `example.com/proxy`, votre application backend devrait produire des liens absolus commençant par `example.com/proxy/`. +La requête est transmise telle-quelle au serveur backend. Cela veut usuellement dire que le service backend doit avoir connaissance du chemin web utilisé pour accéder au service. Par exemple, si l'application est installée sur `__DOMAIN__/proxy`, votre application backend devrait produire des liens absolus commençant par `__DOMAIN__/proxy/`. -Pour supporter les URLs relatives depuis le backend, accéder à l'application via `http(s)://example.com/proxy` produit une redirection permanente (302) vers `http(s)://example.com/proxy/` (avec le slash de fin). Sinon, un lien relatif comme `` essayerait de charger `http(s)://example.com/style.css`, ce qui échouerait. +Pour supporter les URLs relatives depuis le backend, accéder à l'application via `http(s)://__DOMAIN__/proxy` produit une redirection permanente (302) vers `http(s)://__DOMAIN__/proxy/` (avec le slash de fin). Sinon, un lien relatif comme `` essayerait de charger `http(s)://__DOMAIN__/style.css`, ce qui échouerait. Il est possible que votre service backend ne supporte pas de configurer une "base URL" (chemin web personnalisé). Dans ce cas, il faudra installer l'application sur un (sous-)domaine dédié. diff --git a/scripts/change_url b/scripts/change_url index 7083bf2..e73eb60 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,11 +14,9 @@ source _common.sh # Nginx configuration ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) + path="$new_path" domain="$old_domain" -#REMOVEME? proxy_path="$(ynh_app_setting_get --app=$app --key=proxy_path)" -#REMOVEME? assets_path="$(ynh_app_setting_get --app=$app --key=assets_path)" # Validate reverse proxy destination rp_validate_proxy_path @@ -29,17 +27,17 @@ rp_validate_assets_path # Special case for "/" path rp_handle_webroot -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" -#REMOVEME? ynh_add_nginx_config +ynh_backup_if_checksum_is_different --file="$nginx_conf_path" +ynh_add_nginx_config # Move file to new domain if domain has changed -#REMOVEME? if [[ "$old_domain" != "$new_domain" ]]; then -#REMOVEME? new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path $new_nginx_conf_path -#REMOVEME? ynh_store_file_checksum --file="$new_nginx_conf_path" +if [[ "$old_domain" != "$new_domain" ]]; then + new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path $new_nginx_conf_path + ynh_store_file_checksum --file="$new_nginx_conf_path" fi From bdf7da25cd8ca6733b5e8180ceda08d174df63fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:25:03 +0100 Subject: [PATCH 5/9] Update ADMIN.md --- doc/ADMIN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 78a63d1..312012d 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1,8 +1,8 @@ ### Backend web path -The request is transmitted as-is to the backend server. This usually means that the backend service shoudl be aware of the web path used to access the service. For example, if using the application is installed to `example.com/proxy`, your backend application should produce absolute links starting with `example.com/proxy/` too. +The request is transmitted as-is to the backend server. This usually means that the backend service shoudl be aware of the web path used to access the service. For example, if using the application is installed to `__DOMAIN__/proxy`, your backend application should produce absolute links starting with `__DOMAIN__/proxy/` too. -To support relative URLs from the backend, accessing the application via `http(s)://example.com/proxy` will permanent redirect (302) to `http(s)://example.com/proxy/` (trailing slash). Otherwise, a relative link like `` would try to load `http(s)://example.com/style.css` which would fail. +To support relative URLs from the backend, accessing the application via `http(s)://__DOMAIN__/proxy` will permanent redirect (302) to `http(s)://__DOMAIN__/proxy/` (trailing slash). Otherwise, a relative link like `` would try to load `http(s)://__DOMAIN__/style.css` which would fail. It is possible that your backend service does not support setting up a "base URL" (custom web path). In that case, you will have to install the application on a dedicated (sub)domain. From 7313a01d3d669ba29ee13d2b3dec7bf0ff9d62b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:22:14 +0100 Subject: [PATCH 6/9] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 40f38b6..72c52f5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -15,7 +15,7 @@ website = "https://en.wikipedia.org/wiki/Reverse_proxy" [integration] yunohost = ">= 11.2" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +architectures = "all" multi_instance = true ldap = "not_relevant" From 8d5463b70a0e50da43d9c90c1c4109b4485d4a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:22:37 +0100 Subject: [PATCH 7/9] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 72c52f5..824e61d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -23,7 +23,7 @@ ldap = "not_relevant" sso = "not_relevant" disk = "50M" -ram.build = "50M" +ram.build = "90M" ram.runtime = "50M" [install] From ef7c087faecda063228966799533c46a72f76e07 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 29 Nov 2023 09:28:09 +0000 Subject: [PATCH 8/9] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index c6207be..ecfae0b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ Please be aware that SSOWat sends user credentials in plaintext to the backend, **Shipped version:** 0.2~ynh1 - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index b6ba18c..48da124 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,7 +28,6 @@ Attention, SSOWat envoie les identifiants des utilisateurices en clair jusqu'au **Version incluse :** 0.2~ynh1 - ## Documentations et ressources * Site officiel de l’app : From 5cd80a4bc543eed716abdbf34f9afba048e44739 Mon Sep 17 00:00:00 2001 From: eric_G <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 2 Dec 2023 19:37:00 +0100 Subject: [PATCH 9/9] Update manifest.toml Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> --- manifest.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 824e61d..ddccf31 100644 --- a/manifest.toml +++ b/manifest.toml @@ -41,7 +41,6 @@ ram.runtime = "50M" [install.init_main_permission] type = "group" - default = false [install.assets_path] ask.en = "Static assets folder"