From 421971b54e9c7656bc475f2fcd29ceb062d20d9f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 10 Feb 2017 09:37:13 +0100 Subject: [PATCH] Bug 16749: Adjust xmlstarlet calls in koha-functions Content-Type: text/plain; charset=utf-8 --- debian/scripts/koha-functions.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 167998e..30b64cd 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -222,16 +222,14 @@ adjust_paths_dev_install() # corresponding tag in koha-conf.xml local instancename=$1 - local dev_install - - if [ -e /etc/koha/sites/$instancename/koha-conf.xml ]; then - dev_install=$(xmlstarlet sel -t -v 'yazgfs/config/dev_install' /etc/koha/sites/$instancename/koha-conf.xml) - fi + local dev_install=$(run_safe_xmlstarlet $instancename dev_install) if [ "$dev_install" != "" ]; then DEV_INSTALL=1 KOHA_HOME=$dev_install PERL5LIB=$dev_install + else + DEV_INSTALL=0 fi } @@ -244,13 +242,12 @@ get_instances() get_loglevels() { local instancename=$1 - local retval=$(xmlstarlet sel -t -v 'yazgfs/config/zebra_loglevels' /etc/koha/sites/$instancename/koha-conf.xml) + local retval=$(run_safe_xmlstarlet $instancename zebra_loglevels) if [ "$retval" != "" ]; then echo "$retval" else echo "none,fatal,warn" fi - } get_tmpdir() @@ -272,3 +269,18 @@ get_tmpdir() fi echo $(dirname $retval) } + +run_safe_xmlstarlet() +{ + # When running xmlstarlet and the expr is not found, the script may fail + # silently under certain conditions. For instance, script koha-plack + # failed under kohadevbox/jessie. Until we resolve that, this function + # does a grep first (assuming a unique tag). + local instancename=$1 + local myexpr=$2 + if [ -e /etc/koha/sites/$instancename/koha-conf.xml ] && grep -q "<$myexpr>" /etc/koha/sites/$instancename/koha-conf.xml; then + echo $(xmlstarlet sel -t -v "yazgfs/config/$myexpr" /etc/koha/sites/$instancename/koha-conf.xml) + return 0 + fi + return 1 +} -- 2.1.4