From dd681358b4b465e3338a7557da8a54a296733b98 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 1 Mar 2023 10:22:22 -0300 Subject: [PATCH] Bug 33108: Add is_elasticsearch_enabled method to tools This patch adds a way to query if an instance is configured to use ES. To test: 1. Apply this patch 2. Enter KTD as root: $ ktd --shell --root 3. Run: $ source /kohadevbox/koha/debian/scripts/koha-functions.sh 4. Run: $ is_elasticsearch_enabled hola => FAIL: Instance hola doesn't exist (hopefully :-P) 5. Have the SearchEngine syspref set to Elasticsearch 6. Run: $ is_elasticsearch_enabled kohadev && echo "it is" || echo "it isn't" => SUCCESS: "it is" gets printed 7. Set SearchEngine to Zebra 8. Repeat 6 => SUCCESS: "it isn't" gets printed 9. Sign off :-D --- debian/scripts/koha-functions.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 5b81d177ccd..72f64b6de72 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -330,6 +330,19 @@ is_z3950_running() fi } +is_elasticsearch_enabled() +{ + local instancename=$1 + + search_engine=$(koha-shell $instancename -c "/usr/share/koha/bin/admin/koha-preferences get SearchEngine") + + if [ "$search_engine" == "Elasticsearch" ]; then + return 0 + else + return 1 + fi +} + adjust_paths_dev_install() { # Adjust KOHA_HOME, PERL5LIB for dev installs, as indicated by -- 2.34.1