#!/bin/sh

# configdb-dry-run.sh --
# Copy of the supplied configdb.sh with built-in -e and -r removed.
# Experimental SQL review; complete read-only behaviour is unverified.
# Do not pass -e or -r as arguments: this wrapper still forwards them.
#		The default database is defined in the maximo.properties file.
# 		The commandline parameters for overriding the defaults are listed below.
#		Also see javadocs for psdi.configure.ConfigDB and RestoreFromBackup.
#
# -a (db alias)	  Database alias. If not specified, uses mxe.db.url property.
# -d (logfile dir)	  If using the -l parameter, will output logfile to the specified directory.
#			  If not specified, outputs to the MXServer log directory,
#			  which normaly is tools/maximo/log.
# -e			  Causes Sql to be executed.  (Omitted from this launcher.)
# -f (filename)	  Filename for properties file.  If not specified, uses maximo.properties.
#			  (Also see -k parameter for propfile directory.)
# -k (propfile dir)	  Directory for properties file.
#			  (Also see -f parameter for propfile filename.)
# -l                 	  Outputs a detailed log file.
# -o (filename)	  If using the -l parameter, the filename for the logfile.
#			  If not specified, logfile is "ConfigDB" + timestamp + ".log".
#			  (Also see -d parameter for logfile directory.)
# -p (password)	  Password for database connection.
#			  If not specified, uses mxe.db.password property, or "maximo".
# -r 			  Call RestoreFromBackup immediately after ConfigDB ends without error.
#			  Care should be taken when using this param, as there are occasions when
#			  the data in the temp tables (XX+tablename) must be modified before
#			  attempting the Restore.
# -u (username)	  Username for database connection.
#			  If not specified, uses mxe.db.user property, or "maximo".

# Reset arguments just in case you ran the script earlier.
arg1=""
arg2=""
arg3=""
arg4=""
arg5=""
arg6=""
arg7=""
arg8=""
arg9=""
arga=""
argb=""
argc=""
argd=""
arge=""
argf=""
argg=""
argh=""
argi=""
argj=""
argk=""

# Test up to 20 arguments and store them in $arg1 to $argk
if [ "$*" != "" ]
then
  arg1=$1
  shift
fi

if [ "$*" != "" ]
then
  arg2=$1
  shift
fi

if [ "$*" != "" ]
then
  arg3=$1
  shift
fi

if [ "$*" != "" ]
then
  arg4=$1
  shift
fi

if [ "$*" != "" ]
then
  arg5=$1
  shift
fi

if [ "$*" != "" ]
then
  arg6=$1
  shift
fi

if [ "$*" != "" ]
then
  arg7=$1
  shift
fi

if [ "$*" != "" ]
then
  arg8=$1
  shift
fi

if [ "$*" != "" ]
then
  arg9=$1
  shift
fi

if [ "$*" != "" ]
then
  arga=$1
  shift
fi

if [ "$*" != "" ]
then
  argb=$1
  shift
fi

if [ "$*" != "" ]
then
  argc=$1
  shift
fi

if [ "$*" != "" ]
then
  argd=$1
  shift
fi

if [ "$*" != "" ]
then
  arge=$1
  shift
fi

if [ "$*" != "" ]
then
  argf=$1
  shift
fi

if [ "$*" != "" ]
then
  argg=$1
  shift
fi

if [ "$*" != "" ]
then
  argh=$1
  shift
fi

if [ "$*" != "" ]
then
  argi=$1
  shift
fi

if [ "$*" != "" ]
then
  argj=$1
  shift
fi

if [ "$*" != "" ]
then
  argk=$1
  shift
fi

pathToScript=`dirname %0`
. $pathToScript/commonenv.sh

# set DB2DBDFT if run for DB2, uncomment the set command and use the correct value for database name.
# export DB2DBDFT=databasename

../java/jre/bin/java $MEMORY_ARGS -classpath .:./classes:$MAXIMO_CLASSPATH  psdi.configure.ConfigDB -l -k../../applications/maximo/properties $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 $arg9 $arga $argb $argc $argd $arge $argf $argg $argh $argi $argj $argk

exit $?
