From f07b4a7822ea193173e9e48384a039bbafe245f7 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:33:19 +0100 Subject: [PATCH] app: implement subpath support --- README.md | 3 +-- check_process | 7 +++---- conf/nginx.conf | 4 ++-- manifest.json | 10 ++++++++++ scripts/install | 3 ++- scripts/restore | 2 +- scripts/upgrade | 3 ++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d6ac03d..c02ca3b 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,13 @@ You can either : ## What works -* Installation on domain's root +* Installation on domain root or sub-directory * Notification emails * Push notifications * Service control in Yunohost Services panel ## TODO -* Allow installation in sub-directory (only root-domains for now, see [#8](https://github.com/YunoHost-Apps/mattermost_ynh/issues/8)) * LDAP integration (only paid Entreprise Edition, see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) ## About telemetrics diff --git a/check_process b/check_process index d57e774..b6d972e 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Mattermost ; Manifest domain="ynhtests.local" (DOMAIN) - path="" (PATH) + path="/path" (PATH) admin_email="john@gmail.com" admin_password="MattermostPassword!42" admin_locale="fr" @@ -10,6 +10,7 @@ analytics=0 ; Checks pkg_linter=1 + setup_sub_dir=1 setup_root=1 setup_private=1 setup_public=1 @@ -20,14 +21,12 @@ # Checks not supported yet change_url=0 # Checks not applicable - setup_sub_dir=0 setup_nourl=0 - incorrect_path=0 ;;; Levels Level 1=auto Level 2=auto Level 3=auto - Level 4=na + Level 4=auto Level 5=auto Level 6=auto Level 7=auto diff --git a/conf/nginx.conf b/conf/nginx.conf index f2daff7..edbf5b1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ # Directives from the Mattermost installation guide -location ~ /api/v[0-9]+/(users/)?websocket$ { +location ~ __PATH__/api/v[0-9]+/(users/)?websocket$ { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; client_max_body_size 50M; @@ -15,7 +15,7 @@ location ~ /api/v[0-9]+/(users/)?websocket$ { proxy_pass http://127.0.0.1:__PORT__; } -location / { +location __PATH__/ { client_max_body_size 50M; proxy_set_header Connection ""; proxy_set_header Host $http_host; diff --git a/manifest.json b/manifest.json index 44a31c4..d073f82 100644 --- a/manifest.json +++ b/manifest.json @@ -31,6 +31,16 @@ }, "example": "domain.org" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Mattermost", + "fr": "Choisissez un chemin pour Mattermost" + }, + "example": "/chat", + "default": "/chat" + }, { "name": "is_public", "type": "boolean", diff --git a/scripts/install b/scripts/install index b62c3fc..5df8433 100644 --- a/scripts/install +++ b/scripts/install @@ -21,13 +21,13 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC admin_email=$YNH_APP_ARG_ADMIN_EMAIL admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_locale=$YNH_APP_ARG_ADMIN_LOCALE team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME analytics=$YNH_APP_ARG_ANALYTICS -path_url="/" #================================================= # CHECK IF THE APP CAN BE INSTALLED @@ -71,6 +71,7 @@ ynh_webpath_available "$domain" "$path_url" ynh_webpath_register "$app" "$domain" "$path_url" # Store setting ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path "$path_url" #================================================= # FIND AN AVAILABLE PORT diff --git a/scripts/restore b/scripts/restore index d1f4d44..7aab3b3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,7 +21,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) is_public=$(ynh_app_setting_get $app is_public) -path_url="/" +path_url=$(ynh_app_setting_get $app path) final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 965f1f8..a09df26 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) # used during nginx configuration is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app port) mattermost_user="$app" @@ -55,7 +56,7 @@ ynh_clean_setup () { fi # Restore the backup ynh_restore_upgradebackup - + else # Backup restoration is not available: # let's try at least to restart the server.