# Run the OA4MP CLI (command line interface). This will allow you to edit, create or remove
# clients, approvals. It will also allow you to copy one store to another completely.
# Invoke with --help for more information.
#
# The next 5 entries completely determine how this operates. Change these to whatever you want if
# different from the standard install.

OA4MP_ROOT=/opt/oa4mp
DEFAULT_CONFIG=$OA4MP_ROOT/etc/admin-cfg.xml
DEFAULT_TARGET=default
cliJar=$OA4MP_ROOT/lib/oa4mp-cli.jar
logFile=$OA4MP_ROOT/var/log/oa4mp-cli.log

# End of user serviceable parts.

if [[  "$1" = "--help" || $# -gt 2 ]];then
  echo "oa4mp-cli [configName configFile"]
  echo "Start the oa4mp command line admin too with the"
  echo "given configuration name in the given configuration file (full path)."
  echo "No arguments means to use the config named '$DEFAULT_TARGET' in the file  '$DEFAULT_CONFIG'"
  echo "One argument is assumed to be the configuration name in the default config file."
  exit 1
fi

target=${1:-$DEFAULT_TARGET}
adminCfg=${2:-$DEFAULT_CONFIG}

java -jar $cliJar   -cfg $adminCfg -name $target -log $logFile -v

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

exit 0
