# 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 "oa2-cp source [target]"
  echo "Copy the source server to the target server."
  echo "Omitting the target implies the configuration named 'default'"
  exit 1
fi

OA4MP_ROOT=/opt/oa2
DEFAULT_CONFIG=$OA4MP_ROOT/etc/admin-cfg.xml
DEFAULT_TARGET=default
adminJar=$OA4MP_ROOT/lib/oa2-cp.jar
logFile=$OA4MP_ROOT/var/log/oa2-cp.log

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

java -jar $adminJar  -s $source -t $target  -cfg $adminCfg -log $logFile -v

if [ $? != 0 ]; then
  exit 1
fi


exit 0
