#!/bin/bash
source $(cd `dirname $0`; pwd)/common
parameterSize=4

if [ $# = 0 ]
then
	echo "事务日志 redo 工具需要参数："
	echo "1. 数据库名称"
	echo "2. 新建数据库父目录的绝对路径；"
	echo "3. 事务日志目录路径；"
	echo "4. 备份文件绝对路径（空表示没有备份文件，事务日志从头开始redo）。"
else
    needStopServer   #需要停止服务才能使用该工具
    if [ $? = 1 ]
    then
	    if [ $# == $parameterSize ]
	    then
	        java -classpath "$basePath/$version/lib/*:." kd.bos.olap.repairTools.OlapServerToolsMain -allowRunWithDatabase:true -function:transactionLogRedo -functionParameters:$1,$(getAbsolutePath $2),$(getAbsolutePath $3),$(getAbsolutePath $4)
	    elif [ $# == `expr $parameterSize - 1` ]
	    then
	        java -classpath "$basePath/$version/lib/*:." kd.bos.olap.repairTools.OlapServerToolsMain -allowRunWithDatabase:true -function:transactionLogRedo -functionParameters:$1,$(getAbsolutePath $2),$(getAbsolutePath $3),
	    else
	    	echo "参数个数不对。"
	    fi
	fi
fi