1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/xwiki_ynh.git synced 2024-09-03 20:36:11 +02:00

Fix multi instances issues

This commit is contained in:
Josué Tille 2023-12-18 16:22:06 +01:00
parent 4d90fca8cf
commit 54128430bd
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
2 changed files with 34 additions and 26 deletions

View file

@ -19,10 +19,12 @@ if [ $path == '/' ]; then
install_on_root=true install_on_root=true
path2='' path2=''
path3='' path3=''
web_inf_path="$install_dir"/webapps/root/WEB-INF
else else
install_on_root=false install_on_root=false
path2=${path/#\//}/ # path=/xwiki -> xwiki/ path2=${path/#\//}/ # path=/xwiki -> xwiki/
path3=${path/#\//} # path=/xwiki -> xwiki path3=${path/#\//} # path=/xwiki -> xwiki
web_inf_path="$install_dir"/webapps$path/WEB-INF
fi fi
#================================================= #=================================================
@ -32,16 +34,18 @@ fi
enable_super_admin() { enable_super_admin() {
super_admin_pwd=$(ynh_string_random) super_admin_pwd=$(ynh_string_random)
super_admin_config="xwiki.superadminpassword=$super_admin_pwd" super_admin_config="xwiki.superadminpassword=$super_admin_pwd"
ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki.cfg ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki_conf.cfg
chmod 400 /etc/$app/xwiki.cfg ln -f /etc/$app/xwiki_conf.cfg "$web_inf_path"/xwiki.cfg
chown "$app:$app" /etc/$app/xwiki.cfg chmod 400 /etc/$app/xwiki_conf.cfg
chown "$app:$app" /etc/$app/xwiki_conf.cfg
} }
disable_super_admin() { disable_super_admin() {
super_admin_config='#' super_admin_config='#'
ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki.cfg ynh_add_config --template=xwiki.cfg --destination=/etc/$app/xwiki_conf.cfg
chmod 400 /etc/$app/xwiki.cfg ln -f /etc/$app/xwiki_conf.cfg "$web_inf_path"/xwiki.cfg
chown "$app:$app" /etc/$app/xwiki.cfg chmod 400 /etc/$app/xwiki_conf.cfg
chown "$app:$app" /etc/$app/xwiki_conf.cfg
} }
install_exension() { 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.cfg
ynh_secure_remove --file="$install_dir"/webapps/xwiki/WEB-INF/xwiki.properties 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 /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 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 mv "$install_dir"/webapps/xwiki "$install_dir"/webapps/root
elif [ "$path" != xwiki ]; then elif [ "$path" != /root ]; then
if [ "$path" == /root ]; then ynh_die --message='Path "/root" not supported'
ynh_die --message='/root path is not supported as path' elif [ "$path" != /xwiki ]; then
fi
mv "$install_dir"/webapps/xwiki "$install_dir"/webapps$path mv "$install_dir"/webapps/xwiki "$install_dir"/webapps$path
fi fi
} }
add_config() { add_config() {
ynh_add_config --template=hibernate.cfg.xml --destination=/etc/$app/hibernate.cfg.xml 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.cfg --destination=/etc/$app/xwiki_conf.cfg
ynh_add_config --template=xwiki.properties --destination=/etc/$app/xwiki.properties 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() { set_permissions() {

View file

@ -12,8 +12,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ -n "$(ls -A $data_dir)" ]; then if [ -n "$(ls -A $data_dir)" ]; then
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" 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 /var/log/"$app"
mkdir -p /etc/$app mkdir -p /etc/$app
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message='Setting up source files...' --weight=1 ynh_script_progression --message='Setting up source files...' --weight=1
install_source install_source
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message='Adding configuration files...' --weight=1
add_config
set_permissions
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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" 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 # INSTALL EXTENSIONS
#================================================= #=================================================