From 54128430bdcc4d27dd3b8b34aab9f37413892b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 18 Dec 2023 16:22:06 +0100 Subject: [PATCH] Fix multi instances issues --- scripts/_common.sh | 38 ++++++++++++++++++++++---------------- scripts/install | 22 ++++++++++++---------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 64c4d15..c851f6e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,10 +19,12 @@ if [ $path == '/' ]; then install_on_root=true path2='' path3='' + web_inf_path="$install_dir"/webapps/root/WEB-INF else install_on_root=false path2=${path/#\//}/ # path=/xwiki -> xwiki/ path3=${path/#\//} # path=/xwiki -> xwiki + web_inf_path="$install_dir"/webapps$path/WEB-INF fi #================================================= @@ -32,16 +34,18 @@ fi enable_super_admin() { super_admin_pwd=$(ynh_string_random) super_admin_config="xwiki.superadminpassword=$super_admin_pwd" - ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki.cfg - chmod 400 /etc/$app/xwiki.cfg - chown "$app:$app" /etc/$app/xwiki.cfg + ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki_conf.cfg + ln -f /etc/$app/xwiki_conf.cfg "$web_inf_path"/xwiki.cfg + chmod 400 /etc/$app/xwiki_conf.cfg + chown "$app:$app" /etc/$app/xwiki_conf.cfg } disable_super_admin() { super_admin_config='#' - ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki.cfg - chmod 400 /etc/$app/xwiki.cfg - chown "$app:$app" /etc/$app/xwiki.cfg + ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki_conf.cfg + ln -f /etc/$app/xwiki_conf.cfg "$web_inf_path"/xwiki.cfg + chmod 400 /etc/$app/xwiki_conf.cfg + chown "$app:$app" /etc/$app/xwiki_conf.cfg } install_exension() { @@ -139,27 +143,29 @@ install_source() { ynh_secure_remove --file="$install_dir"/webapps/xwiki/WEB-INF/xwiki.cfg ynh_secure_remove --file="$install_dir"/webapps/xwiki/WEB-INF/xwiki.properties + ynh_secure_remove --file="$install_dir"/webapps/root 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 + elif [ "$path" != /root ]; then + ynh_die --message='Path "/root" not supported' + elif [ "$path" != /xwiki ]; then mv "$install_dir"/webapps/xwiki "$install_dir"/webapps$path fi } add_config() { ynh_add_config --template=hibernate.cfg.xml --destination=/etc/$app/hibernate.cfg.xml - ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki.cfg - ynh_add_config --template=xwiki.properties --destination=/etc/$app/xwiki.properties + ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki_conf.cfg + ynh_add_config --template=xwiki.properties --destination=/etc/$app/xwiki_conf.properties + + # Note that using /etc/xwiki/xwiki.cfg or /etc/xwiki/xwiki.properties is hard coded on the application + # And using this break multi instance feature so we must use an other path + # Note that symlink don't work. So use hard link instead. + ln -f /etc/$app/xwiki_conf.cfg "$web_inf_path"/xwiki.cfg + ln -f /etc/$app/xwiki_conf.properties "$web_inf_path"/xwiki.properties } set_permissions() { diff --git a/scripts/install b/scripts/install index 0e42d60..115aa71 100755 --- a/scripts/install +++ b/scripts/install @@ -12,8 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= if [ -n "$(ls -A $data_dir)" ]; then old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" @@ -25,10 +23,22 @@ fi mkdir -p /var/log/"$app" mkdir -p /etc/$app +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + ynh_script_progression --message='Setting up source files...' --weight=1 install_source +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message='Adding configuration files...' --weight=1 + +add_config +set_permissions + #================================================= # SYSTEM CONFIGURATION #================================================= @@ -44,14 +54,6 @@ yunohost service add "$app" --description=XWiki --log="/var/log/$app/$app.log" ynh_use_logrotate --logfile "/var/log/$app" -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message='Adding configuration files...' --weight=1 - -add_config -set_permissions - #================================================= # INSTALL EXTENSIONS #=================================================