From 08054e3b72171c98f860d5aac6959781fe318355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 12 Dec 2023 19:43:51 +0100 Subject: [PATCH] Add path management --- conf/nginx.conf | 2 +- conf/xwiki.cfg | 2 +- manifest.toml | 4 ++++ scripts/_common.sh | 29 +++++++++++++++++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7353fb7..8981c89 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass http://127.0.0.1:__PORT__/__PATH2__; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; diff --git a/conf/xwiki.cfg b/conf/xwiki.cfg index 5a5a590..0113768 100644 --- a/conf/xwiki.cfg +++ b/conf/xwiki.cfg @@ -251,7 +251,7 @@ xwiki.store.migration=1 #-# instance. #-# For example: #-# xwiki.webapppath=xwiki -# xwiki.webapppath= +xwiki.webapppath=__PATH3__ #-# The default servlet mapping name to use in the generated URLs. The right value is taken from the request URL, #-# preserving the requested servlet mapping, so setting this is not recommended in most cases. If set, the value should #-# contain a trailing /, but not a leading one. For example: diff --git a/manifest.toml b/manifest.toml index 0c19d25..8ce10e7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -31,6 +31,10 @@ ram.runtime = "1G" [install.domain] type = "domain" + [install.path] + type = "path" + default = "/xwiki" + [install.install_standard_flavor] ask.en = "Would you like to install the Standard Flavor ?" help.en = "See https://extensions.xwiki.org/xwiki/bin/view/Extension/XWiki%20Standard%20Flavor/ for more informations." diff --git a/scripts/_common.sh b/scripts/_common.sh index 3295f3c..017433e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,6 +15,16 @@ else distribution_default_ui='#' fi +if [ $path == '/' ]; then + install_on_root=true + path2='' + path3='' +else + install_on_root=false + path2=${path/#\//}/ + path3=${path/#\//} +fi + #================================================= # PERSONAL HELPERS #================================================= @@ -49,13 +59,13 @@ install_exension() { chown root:root $temp_dir ynh_add_config --template=install_extensions.xml --destination=$temp_dir/install_extensions.xml - status_raw=$($curl -i --user "superadmin:$super_admin_pwd" -X PUT -H 'Content-Type: text/xml' "http://localhost:$port/xwiki/rest/jobs?jobType=install&async=true" --upload-file $temp_dir/install_extensions.xml) + status_raw=$($curl -i --user "superadmin:$super_admin_pwd" -X PUT -H 'Content-Type: text/xml' "http://localhost:$port$path/rest/jobs?jobType=install&async=true" --upload-file $temp_dir/install_extensions.xml) state_request=$(echo $status_raw | $xq -x '//jobStatus/ns2:state') while true; do sleep 5 - status_raw=$($curl --user "superadmin:$super_admin_pwd" -X GET -H 'Content-Type: text/xml' "http://localhost:$port/xwiki/rest/jobstatus/extension/provision/$job_id") + status_raw=$($curl --user "superadmin:$super_admin_pwd" -X GET -H 'Content-Type: text/xml' "http://localhost:$port$path/rest/jobstatus/extension/provision/$job_id") state_request=$(echo "$status_raw" | $xq -x '//jobStatus/state') if [ -z "$state_request" ]; then @@ -77,7 +87,7 @@ install_exension() { wait_xwiki_started() { local res while echo "$res" | grep -q 'meta http-equiv="refresh" content="1"'; do - res=($curl "http://localhost:$port/xwiki/bin/view/Main/") + res=($curl "http://localhost:$port$path/bin/view/Main/") sleep 10 done } @@ -93,7 +103,7 @@ wait_for_flavor_install() { wait_xwiki_started while true; do - status_raw=$($curl --user "superadmin:$super_admin_pwd" -X GET -H 'Content-Type: text/xml' "http://localhost:$port/xwiki/rest/jobstatus/extension/action/$flavor_job_id") + status_raw=$($curl --user "superadmin:$super_admin_pwd" -X GET -H 'Content-Type: text/xml' "http://localhost:$port$path/rest/jobstatus/extension/action/$flavor_job_id") state_request=$(echo "$status_raw" | $xq -x '//jobStatus/state') if [ -z "$state_request" ]; then @@ -124,6 +134,17 @@ install_source() { ln -s /var/log/"$app" "$install_dir"/logs ln -s /etc/$app/xwiki.cfg "$install_dir"/webapps/xwiki/WEB-INF/xwiki.cfg ln -s /etc/$app/xwiki.properties "$install_dir"/webapps/xwiki/WEB-INF/xwiki.properties + + if $install_on_root; then + ynh_secure_remove --file="$install_dir"/webapps/root + ynh_secure_remove --file="$install_dir"/jetty/contexts/xwiki.xml + mv "$install_dir"/webapps/xwiki "$install_dir"/webapps/root + elif [ "$path" != xwiki ]; then + if [ "$path" == /root ]; then + ynh_die --message='/root path is not supported as path' + fi + mv "$install_dir"/webapps/xwiki "$install_dir"/webapps$path + fi } add_config() {