# Run the OA4MP client (a command line interface client). This allows you to check the complete
# lifecycle of getting a cert, refresh tokens and user info from the command line -- almost.
# 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=${OA4MP_HOME}
DEFAULT_CONFIG="$OA4MP_ROOT"etc/cfg.xml
DEFAULT_TARGET=default
clientJar="$OA4MP_ROOT"lib/clc.jar
logFile="$OA4MP_ROOT"var/log/clc.log

# End of user serviceable parts.

if [[  "$1" = "--help" || $# -gt 2 ]];then
  echo "clc [configName configFile"]
  echo "Start the OAuth 2 forMyProxy command line client 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}
clientCfg=${2:-$DEFAULT_CONFIG}

java  -jar $clientJar   -cfg $clientCfg -name $target -log $logFile

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

exit 0
