From 70d62979cead67da48522d275a57b9b76616bf42 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 14 Aug 2020 01:49:40 +0000 Subject: [PATCH] Bug 25778: Fix var scope in koha-plack for PERL5LIB and KOHA_HOME Currently, if a koha-plack is given multiple instances, it will create duplicate $KOHA_HOME/installer and $KOHA_HOME/installer/lib entries in PERL5LIB as these changes are done at the global rather than local level. This issue can only be seen in non-dev Koha, since dev Koha installs rewrite PERL5LIB. This patch localizes PERL5LIB to each instance. To test dev installs: 0. cp debian/scripts/koha-plack /usr/sbin/koha-plack 1. koha-plack --restart kohadev 2. Note that nothing breaks To test non-dev installs: 0. Don't replace /usr/sbin/koha-plack yet 1. Create multiple non-dev installs with plack enabled and running 2. Set up one of these non-dev installs so you can use the web UI (that is beyong the scope of this test plan) 3. koha-plack --restart test1 test2 test3 4. For test3, go to /cgi-bin/koha/about.pl 5. Note that there are duplicate /usr/share/koha/installer and /usr/share/koha/lib/installer entries in PERL5LIB 6. cp debian/scripts/koha-plack /usr/sbin/koha-plack 7. koha-plack --restart test1 test2 test3 8. For test3, go to /cgi-bin/koha/about.pl 9. Note that there are no duplicates entries in PERL5LIB Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- debian/scripts/koha-plack | 90 +++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index 90da6cbd36..3dcce331a9 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -328,6 +328,50 @@ set_action() fi } +_do_instance() { + local name=$1 + local PERL5LIB=$PERL5LIB + local KOHA_HOME=$KOHA_HOME + local DEV_INSTALL=$DEV_INSTALL + + adjust_paths_dev_install $name + PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer + # If debug mode is enabled, add the debugger lib path + # to PERL5LIB if appropriate + #FIXME: many of these variables should be set in a higher scope + if [ "$debug_mode" = "yes" ]; then + if [ "$debugger_path" != "" ]; then + PERL5LIB="${debugger_path}":$PERL5LIB + fi + export PERL5DB="BEGIN { require q(${debugger_path}/perl5db.pl) }" + export PERLDB_OPTS="RemotePort=${debugger_location} async=1 LogFile=/var/log/koha/${name}/plack-debug.log" + export DBGP_IDEKEY=${debugger_key} + export PLACK_DEBUG=1 + export PERL5OPT="-d" + fi + + case $op in + "start") + start_plack $name + ;; + "stop") + stop_plack $name + ;; + "restart") + restart_plack $name + ;; + "enable") + enable_plack $name + ;; + "disable") + disable_plack $name + ;; + *) + usage + ;; + esac +} + STARMAN=$(which starman) op="" quiet="no" @@ -383,52 +427,16 @@ done [ "${quiet}" != "yes" ] && check_env_and_warn +export PERL5LIB +export DEV_INSTALL +export KOHA_HOME + if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do if is_instance $name; then - - adjust_paths_dev_install $name - export DEV_INSTALL - export KOHA_HOME - PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer - # If debug mode is enabled, add the debugger lib path - # to PERL5LIB if appropriate - if [ "$debug_mode" = "yes" ]; then - if [ "$debugger_path" != "" ]; then - PERL5LIB="${debugger_path}":$PERL5LIB - fi - export PERL5DB="BEGIN { require q(${debugger_path}/perl5db.pl) }" - export PERLDB_OPTS="RemotePort=${debugger_location} async=1 LogFile=/var/log/koha/${name}/plack-debug.log" - export DBGP_IDEKEY=${debugger_key} - export PLACK_DEBUG=1 - export PERL5OPT="-d" - fi - - export PERL5LIB - - case $op in - "start") - start_plack $name - ;; - "stop") - stop_plack $name - ;; - "restart") - restart_plack $name - ;; - "enable") - enable_plack $name - ;; - "disable") - disable_plack $name - ;; - *) - usage - ;; - esac - + _do_instance $name else if [ "$quiet" = "no" ]; then log_daemon_msg "Error: Invalid instance name $name" -- 2.24.1 (Apple Git-126)