#!/bin/sh
# Author:   Thien Ho <thien@bibliofiche.com>
# Created:  Tue, Feb 21, 2006 @ 13:47:18 EST
# Updated:
# - 

ZPORT=210

# Source common functions
#. /data/idzebra-210/zebra.function
. /etc/opals/function

##if [ $# -ne 1 ]; then
##    echo Error;
##fi



cd $ZROOT/$ZPORT

# It's recommended to use database in file zebra.db.
#  - Directory $ZROOT/$ZPORT/record might store unused database.
#  - zebra.db has database order
#zList=`ls $ZROOT/$ZPORT/record`
zList=`cat $ZROOT/$ZPORT/zebra.db`

CUR_DATETIME=`currentDateTime`

echo OPALS::$CUR_DATETIME
echo OPALS::creating new index: starting...

# Create new zebraidx.log
createIndexLog

initIndex
#cd $ZROOT/$ZPORT
#zindex init
for zdb in $zList; do
    createDatabase $zdb
    updateIndex $zdb
done

# Make backup for quick restoration
# Create extra backup???
copyIndexFile


echo OPALS::creating new index: done.

exit
