# Copy the given source server to the local machine. If only one argument is
# supplied, the assumption is that it is the source.
#
# Note that this returns no output generally, just a return code
# of 0 if success and 1 otherwise. It is intended to be invoked
# from other shell scripts.
# It may be manually invoked and run
if [[ $# -eq 0 || $# -gt 2 ]];then
  echo "oa4mp-cp-verifier source [target]"
  echo "Copy the source server to the target server,then verify EVERY entry"
  echo "Omitting the target implies localhost"
  exit 1
fi
OA4MP_ROOT=/opt/oa4mp
DEFAULT_CONFIG=$OA4MP_ROOT/etc/admin-cfg.xml
DEFAULT_TARGET=localhost
adminJar=$OA4MP_ROOT/lib/oa4mp-cp-verifier.jar
logFile=$OA4MP_ROOT/var/log/oa4mp-cp-verifier.log
adminCfg=#OA4MP_ROOT/etc/admin-cfg.xml


source=$1
target=${2:-$DEFAULT_TARGET}

# copy source to target. Depending on the size, this might take a bit of time.
java  $adminJar  -s $source -t $target  -cfg $adminCfg -log $logFile -v
if [ $? != 0 ]; then
  exit 1
fi

exit 0
