#!/bin/sh
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2013-2019 Open Source Solution Technology Corporation
# All Rights Reserved
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the License). You may not use this file except in
# compliance with the License.
#
# You can obtain a copy of the License at
# http://forgerock.org/license/CDDLv1.0.html
# See the License for the specific language governing
# permission and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# Header Notice in each file and include the License file
# at http://forgerock.org/license/CDDLv1.0.html
# If applicable, add the following below the CDDL Header,
# with the fields enclosed by brackets [] replaced by
# your own identifying information:
# "Portions Copyrighted [year] [name of copyright owner]"
#

function usage {
  echo "Usage: ssoupgrader -f|--file configuration file [--acceptLicense]"
  echo ""
}

if [ $# -ge 4 ] ; then
  usage
  exit
fi

if [ "$1" = "-f" -o "$1" = "--file"  ] ; then
  config="$2"
fi

if [ "$config" = "" ] ; then
  usage
  exit
fi

if [ $# -eq 3 -a "$3" != "--acceptLicense" ]; then
  usage
  exit
fi

if [ -z "$JAVA_HOME" ] ; then
        JAVA_HOME="/usr/lib/jvm/jre-11-openjdk"
fi

TOOLS_HOME="/opt/osstech/share/openam14/ssoConfigTools"

MAIN_JAR="$TOOLS_HOME/lib/openam-upgrade-tool-14.0.0.jar"

$JAVA_HOME/bin/java -Xms256m -Xmx512m  \
    -jar $MAIN_JAR -f $config $3
