From 617d9810b497ec9f92e97f079abd11a5b698f80f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 24 Jul 2025 15:49:38 +0200 Subject: [PATCH] Bug 39740: Replace envvar check by calling is_git_install on instance level Content-Type: text/plain; charset=utf-8 Replace the $GIT_INSTALL check by is_git_install. Some scripts did call is_git_install once while potentially looping over multiple instances. Note: koha-reset-passwd only runs on one instance (unlike most). Test plan: Check/adjust git_install and test_system in koha-conf.xml for used instances. cp debian/scripts/koha-functions.sh /usr/share/koha/bin/ cp debian/scripts/koha-* /usr/sbin/ Note: We will still test koha-plack and -z3950-responder later. Test running a few of the other changed koha-* scripts on one or more instances. Verify that things work as expected. Signed-off-by: Marcel de Rooy --- debian/scripts/koha-elasticsearch | 13 +++---------- debian/scripts/koha-es-indexer | 16 ++++------------ debian/scripts/koha-indexer | 20 +++++++------------- debian/scripts/koha-rebuild-zebra | 15 ++++----------- debian/scripts/koha-reset-passwd | 13 +++---------- debian/scripts/koha-sip | 2 +- debian/scripts/koha-sitemap | 12 +++--------- debian/scripts/koha-upgrade-schema | 16 ++++++++-------- debian/scripts/koha-worker | 16 ++++------------ debian/scripts/koha-z3950-responder | 11 ++--------- 10 files changed, 39 insertions(+), 95 deletions(-) diff --git a/debian/scripts/koha-elasticsearch b/debian/scripts/koha-elasticsearch index 05cda37fc6..65bd746e53 100755 --- a/debian/scripts/koha-elasticsearch +++ b/debian/scripts/koha-elasticsearch @@ -84,12 +84,6 @@ run_rebuild_elasticsearch() # read instance name and eliminate instance name from params local name=$1; shift - if [ "$GIT_INSTALL" = "" ]; then - KOHA_BINDIR=${KOHA_HOME}/bin - else - KOHA_BINDIR=${KOHA_HOME}/misc - fi - if [ "${clo_commit_size}" -gt 0 ] 2>/dev/null; then commit_size=${clo_commit_size} fi @@ -120,8 +114,9 @@ run_rebuild_elasticsearch() rebuild_opts="${rebuild_opts} -v" fi + # KOHA_HOME and KOHA_BINDIR may have been adjusted/set by adjust_paths_git_install if koha-shell \ - -c "${KOHA_BINDIR}/search_tools/rebuild_elasticsearch.pl ${rebuild_opts}" \ + -c "${KOHA_HOME}/${KOHA_BINDIR}/search_tools/rebuild_elasticsearch.pl ${rebuild_opts}" \ ${name}; then return 0 else @@ -177,9 +172,6 @@ while [ -n "$*" ]; do shift done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 - # Parse command line. if [ $# -lt 1 ]; then usage @@ -190,6 +182,7 @@ fi for name in "$@" do if is_instance $name; then + adjust_paths_git_install $name if [ "${op}" = "rebuild" ]; then if ! run_rebuild_elasticsearch $name; then warn "Something went wrong rebuilding indexes for ${name}" diff --git a/debian/scripts/koha-es-indexer b/debian/scripts/koha-es-indexer index 0813db95d6..9c2b9786c7 100755 --- a/debian/scripts/koha-es-indexer +++ b/debian/scripts/koha-es-indexer @@ -198,24 +198,16 @@ while [ $# -gt 0 ]; do done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 - -if [ "$GIT_INSTALL" = "" ]; then - worker_DAEMON="${KOHA_HOME}/bin/workers/es_indexer_daemon.pl" -else - worker_DAEMON="${KOHA_HOME}/misc/workers/es_indexer_daemon.pl" -fi - -# PERL5LIB has been read from etc/default -export PERL5LIB - 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 + worker_DAEMON="${KOHA_HOME}/${KOHA_BINDIR}/workers/es_indexer_daemon.pl" + export PERL5LIB + case $op in "start") start_es_indexer $name diff --git a/debian/scripts/koha-indexer b/debian/scripts/koha-indexer index 5bb3b5c66e..277256012b 100755 --- a/debian/scripts/koha-indexer +++ b/debian/scripts/koha-indexer @@ -194,19 +194,9 @@ while [ $# -gt 0 ]; do done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 - # Check if an alternate indexer has been set if [ ! -z "$ALTERNATE_INDEXER_DAEMON" ]; then INDEXER_DAEMON="$ALTERNATE_INDEXER_DAEMON" -else - # We default to rebuild_zebra.pl if no alternate indexer set - if [ "$GIT_INSTALL" = "" ]; then - INDEXER_DAEMON="${KOHA_HOME}/bin/migration_tools/rebuild_zebra.pl" - else - INDEXER_DAEMON="${KOHA_HOME}/misc/migration_tools/rebuild_zebra.pl" - fi fi if [ $INDEXER_TIMEOUT -lt 1 ]; then @@ -219,15 +209,19 @@ if [ -z "$INDEXER_PARAMS" ]; then INDEXER_PARAMS="-daemon -sleep $INDEXER_TIMEOUT $DEBUG" fi -# PERL5LIB has been read from etc/default -export PERL5LIB - if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do if is_instance $name; then + adjust_paths_git_install $name + if [ -z "$ALTERNATE_INDEXER_DAEMON" ]; then + # We default to rebuild_zebra.pl if no alternate indexer set + INDEXER_DAEMON="${KOHA_HOME}/${KOHA_BINDIR}/migration_tools/rebuild_zebra.pl" + fi + export PERL5LIB + case $op in "start") start_indexer $name diff --git a/debian/scripts/koha-rebuild-zebra b/debian/scripts/koha-rebuild-zebra index 10036d0f82..bcdd79fd49 100755 --- a/debian/scripts/koha-rebuild-zebra +++ b/debian/scripts/koha-rebuild-zebra @@ -56,18 +56,12 @@ run_rebuild_zebra() [ "${full_reindex}" = "yes" ] || [ "${force}" = "yes" ] ; then - if [ "$GIT_INSTALL" = "" ]; then - KOHA_BINDIR=$KOHA_HOME/bin - else - KOHA_BINDIR=$KOHA_HOME/misc - fi - # TODO: This comment is here to remind us that we should make # rebuild_zebra.pl return error codes on failure if sudo -u "$instancename-koha" -H \ env PERL5LIB=$PERL5LIB \ KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \ - $KOHA_BINDIR/migration_tools/rebuild_zebra.pl $@ ; then + $KOHA_HOME/$KOHA_BINDIR/migration_tools/rebuild_zebra.pl $@ ; then return 0 else return 1 @@ -148,10 +142,6 @@ while [ -n "$*" ]; do shift done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 - -# Parse command line. if [ $# -lt 1 ]; then if [ "$quiet" = "no" ]; then usage @@ -165,6 +155,9 @@ fi for name in "$@" do if is_instance $name; then + + adjust_paths_git_install $name + if [ "$biblios" = "yes" ]; then if ! run_rebuild_zebra $name \ -b $opt_verbose $opt_idx $opts_other; then diff --git a/debian/scripts/koha-reset-passwd b/debian/scripts/koha-reset-passwd index 52f202e046..ab14a1ff06 100755 --- a/debian/scripts/koha-reset-passwd +++ b/debian/scripts/koha-reset-passwd @@ -45,19 +45,10 @@ set_password() local instancename=$1 local userid=$2 - # Optionally use alternative paths for a dev install - adjust_paths_git_install $1 - - if [ "$GIT_INSTALL" = "" ]; then - KOHA_BINDIR=$KOHA_HOME/bin - else - KOHA_BINDIR=$KOHA_HOME/misc - fi - if sudo -u "$instancename-koha" -H \ env PERL5LIB=$PERL5LIB \ KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \ - $KOHA_BINDIR/admin/set_password.pl --userid $userid ; then + $KOHA_HOME/$KOHA_BINDIR/admin/set_password.pl --userid $userid ; then return 0 else @@ -72,6 +63,8 @@ fi instance="$1" shift +# Adjust KOHA_HOME, KOHA_BINDIR if needed +adjust_paths_git_install $instance for userid in "$@" do diff --git a/debian/scripts/koha-sip b/debian/scripts/koha-sip index da11a08492..d4648d121f 100755 --- a/debian/scripts/koha-sip +++ b/debian/scripts/koha-sip @@ -70,7 +70,7 @@ start_sip() adjust_paths_git_install $name export KOHA_HOME PERL5LIB - if [ "$GIT_INSTALL" = "" ]; then + if ! is_git_install $name; then LIBDIR=$KOHA_HOME/lib else LIBDIR=$KOHA_HOME diff --git a/debian/scripts/koha-sitemap b/debian/scripts/koha-sitemap index eaa2dd6b62..214e03fcc9 100755 --- a/debian/scripts/koha-sitemap +++ b/debian/scripts/koha-sitemap @@ -110,7 +110,7 @@ generate_sitemap() if sudo -u "$instance-koha" -H \ env PERL5LIB=$PERL5LIB \ KOHA_CONF="/etc/koha/sites/$instance/koha-conf.xml" \ - $KOHA_BINDIR/cronjobs/sitemap.pl \ + $KOHA_HOME/$KOHA_BINDIR/cronjobs/sitemap.pl \ --dir $sitemapdir ; then return 0 else @@ -171,20 +171,14 @@ while [ $# -gt 0 ]; do done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 -if [ "$GIT_INSTALL" = "" ]; then - KOHA_BINDIR=$KOHA_HOME/bin -else - KOHA_BINDIR=$KOHA_HOME/misc -fi - if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do if is_instance $name; then + adjust_paths_git_install $name + case $op in "generate") generate_sitemap $name diff --git a/debian/scripts/koha-upgrade-schema b/debian/scripts/koha-upgrade-schema index fc6aaf8326..d985cd7861 100755 --- a/debian/scripts/koha-upgrade-schema +++ b/debian/scripts/koha-upgrade-schema @@ -29,17 +29,17 @@ else exit 1 fi -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 -if [ "$GIT_INSTALL" = "" ]; then - CGI_PATH=$KOHA_HOME/intranet/cgi-bin -else - CGI_PATH=$KOHA_HOME -fi - for name in "$@" do if is_instance $name; then + + adjust_paths_git_install $name + if ! is_git_install $name; then + CGI_PATH=$KOHA_HOME/intranet/cgi-bin + else + CGI_PATH=$KOHA_HOME + fi + echo "Upgrading database schema for $name" if KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \ PERL5LIB=$PERL5LIB \ diff --git a/debian/scripts/koha-worker b/debian/scripts/koha-worker index 31abfdac41..a72536a426 100755 --- a/debian/scripts/koha-worker +++ b/debian/scripts/koha-worker @@ -211,24 +211,16 @@ while [ $# -gt 0 ]; do done -# Optionally use alternative paths for a dev install -adjust_paths_git_install $1 - -if [ "$GIT_INSTALL" = "" ]; then - worker_DAEMON="${KOHA_HOME}/bin/workers/background_jobs_worker.pl" -else - worker_DAEMON="${KOHA_HOME}/misc/workers/background_jobs_worker.pl" -fi - -# PERL5LIB has been read from etc/default -export PERL5LIB - if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do if is_instance $name; then + adjust_paths_git_install $name + worker_DAEMON="${KOHA_HOME}/${KOHA_BINDIR}/workers/background_jobs_worker.pl" + export PERL5LIB + case $op in "start") start_worker $name $queue diff --git a/debian/scripts/koha-z3950-responder b/debian/scripts/koha-z3950-responder index 79fe160908..c43493156b 100755 --- a/debian/scripts/koha-z3950-responder +++ b/debian/scripts/koha-z3950-responder @@ -85,13 +85,7 @@ start_z3950() daemonize="-D -d ${instancename}-koha-z3950" logging="-l /var/log/koha/${instancename}/z3950.log" - if [ "$GIT_INSTALL" = "1" ]; then - MISCDIR=$KOHA_HOME/misc - else - MISCDIR=/usr/share/koha/bin - fi - - Z3950RESPONDER="/usr/bin/perl $MISCDIR/z3950_responder.pl" + Z3950RESPONDER="/usr/bin/perl $KOHA_HOME/$KOHA_BINDIR/z3950_responder.pl" if [ "$debug_mode" = "yes" ]; then if [ "$GIT_INSTALL" = "1" ]; then warn "Not a dev install, disabling debug mode" @@ -99,7 +93,7 @@ start_z3950() environment="development" daemonize="" logging="" # remote debugger takes care - Z3950RESPONDER="/usr/bin/perl -d ${MISCDIR}/z3950_responder.pl" + Z3950RESPONDER="/usr/bin/perl -d $KOHA_HOME/$KOHA_BINDIR/z3950_responder.pl" fi fi @@ -317,7 +311,6 @@ if [ $# -gt 0 ]; then export DBGP_IDEKEY=${debugger_key} export PERL5OPT="-d" fi - export PERL5LIB case $op in -- 2.39.5