[Koha-patches] [PATCH 3/3] Bug 7286: followup fix rebuild_zebra.pl to add rebuild_zebra_sliced.zsh

Stéphane Delaune stephane.delaune at biblibre.com
Fri Feb 10 12:09:16 CET 2012


---
 misc/migration_tools/rebuild_zebra_sliced.zsh |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/misc/migration_tools/rebuild_zebra_sliced.zsh b/misc/migration_tools/rebuild_zebra_sliced.zsh
index b6af48c..9a40252 100755
--- a/misc/migration_tools/rebuild_zebra_sliced.zsh
+++ b/misc/migration_tools/rebuild_zebra_sliced.zsh
@@ -20,6 +20,7 @@
 INCREMENT=$1
 BIBLIOSTART=$2
 BIBLIOEND=$3
+TEMPDIRECTORY=$4
 
 #echo " | $INCREMENT , $BIBLIOSTART , $BIBLIOEND | ";
 # this script rebuild the zebra index recursively
@@ -52,15 +53,21 @@ $sthlastbiblionumber->execute();
 my ( $lastbiblionumber ) = $sthlastbiblionumber->fetchrow_array; print $lastbiblionumber;'`
 #echo $lastbiblionumber;
 let "maxbiblionumber = $lastbiblionumber + 1"
-if [ $# = 2 ]
+if [ $# = 3 ]
 then
+    TEMPDIRECTORY=/tmp/rebuild
+elif [ $# = 2 ]
+then
+    TEMPDIRECTORY=/tmp/rebuild
     BIBLIOEND=$lastbiblionumber
 elif [ $# = 1 ]
 then
+    TEMPDIRECTORY=/tmp/rebuild
     BIBLIOSTART=0
     BIBLIOEND=$lastbiblionumber
 elif [ $# = 0 ]
 then
+    TEMPDIRECTORY=/tmp/rebuild
     INCREMENT=10000
     BIBLIOSTART=0
     BIBLIOEND=$lastbiblionumber
@@ -102,11 +109,21 @@ fi
     else
         rm `dirname $0`/logs/*
     fi
+    ls $TEMPDIRECTORY >/dev/null 2>&1
+    if [ $? != 0 ]
+    then
+        mkdir $TEMPDIRECTORY
+        if [ $? != 0 ]
+        then
+            echo "can't create dir $TEMPDIRECTORY"
+            exit 2
+        fi
+    fi
     #/home/koha/src/misc/migration_tools/rebuild_zebra.pl -r -b -v -x -nosanitize -length 1 -offset 1
     for ((i=$BIBLIOSTART ; i<$BIBLIOEND ; i=i+$INCREMENT))
     do
         echo "I = " $i "with increment " $INCREMENT
-        `dirname $0`/rebuild_zebra.pl -b -v -x -nosanitize -d /tmp/rebuild -k -length $INCREMENT -offset $i > `dirname $0`/logs/rebuild$INCREMENT.$i.log 2> `dirname $0`/logs/rebuild$INCREMENT.$i.err
+        `dirname $0`/rebuild_zebra.pl -b -v -x -nosanitize -d $TEMPDIRECTORY -k -length $INCREMENT -offset $i > `dirname $0`/logs/rebuild$INCREMENT.$i.log 2> `dirname $0`/logs/rebuild$INCREMENT.$i.err
         if (($INCREMENT >1 ));
         then
             if { grep -q "previous transaction" `dirname $0`/logs/rebuild$INCREMENT.$i.err } ;
-- 
1.7.0.4



More information about the Koha-patches mailing list