From 84b83cec6a28d66475158c246b80951ea3845dee Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Thu, 21 May 2015 15:18:48 +1200 Subject: [PATCH] Bug 14106: koha-start-zebra ensures a correct link exists When koha-start-zebra starts, it first checks to see if there is a symlink (/var/lib/koha/zebramodules) pointing to the location that contains the zebra modules. If not, it makes one. It will also remove and replace incorrect ones. Testing: * Run koha-start-zebra, see that /var/lib/koha/zebramodules exists and points to whatever directory contains your zebra modules. * Run koha-start-zebra, see that nothing has changed * Delete the symlink, run koha-start-zebra, see that it puts it back, * Make a new symlink that points to the wrong place, run koha-start-zebra, see that it replaces it with a correct one. --- debian/scripts/koha-start-zebra | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-start-zebra b/debian/scripts/koha-start-zebra index ce6c469..0430460 100755 --- a/debian/scripts/koha-start-zebra +++ b/debian/scripts/koha-start-zebra @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # koha-start-zebra - Start Zebra for named Koha instances # Copyright 2010 Catalyst IT, Ltd @@ -56,6 +56,51 @@ start_zebra_instance() return 1 } +path_to_zebra_modules() +{ + # The list of paths to check + local paths=( + /usr/lib/x86_64-linux-gnu/idzebra-2.0/modules/ + /usr/lib/idzebra-2.0/modules/ + /usr/lib/i386-linux-gnu/idzebra-2.0/modules/ + /usr/lib/aarch64-linux-gnu/idzebra-2.0/modules/ + /usr/lib/arm-linux-gnueabi/idzebra-2.0/modules/ + /usr/lib/arm-linux-gnueabihf/idzebra-2.0/modules/ + /usr/lib/mips-linux-gnu/idzebra-2.0/modules/ + /usr/lib/mipsel-linux-gnu/idzebra-2.0/modules/ + /usr/lib/powerpc-linux-gnu/idzebra-2.0/modules/ + /usr/lib/powerpc64le-linux-gnu/idzebra-2.0/modules/ + /usr/lib/s390x-linux-gnu/idzebra-2.0/modules/ + ) + for p in "${paths[@]}"; do + if [ -e $p/mod-dom.so ] ; then + echo $p + return 0 + fi + done +} + +set_up_module_link() +{ + # Find where the module is + local modules=$(path_to_zebra_modules) + if [ -z $modules ] ; then + die "Unable to find zebra modules on your system." + fi + + linkpath=/var/lib/koha/zebramodules + # If the link exists, check the target of it. If it doesn't match what + # we have, we'll replace it. + if [ -L $linkpath ] ; then + if [ $( /bin/readlink $linkpath ) = $modules ] ; then + # Alles in Ordnung + return 0 + fi + fi + rm -f $linkpath + ln -s $modules $linkpath +} + usage() { local scriptname=$0 @@ -67,6 +112,7 @@ Usage: $scriptname instancename1 instancename2... EOF } +set_up_module_link # Parse command line. #[ $# -ge 1 ] || ( usage ; die "Missing instance name..." ) -- 2.1.0