#!/bin/sh

# Copyright 2006-2011 Amazon.com, Inc. or its affiliates.  All Rights Reserved.  Licensed under the
# Amazon Software License (the "License").  You may not use this file except in compliance with the License. A copy of the
# License is located at http://aws.amazon.com/asl or in the "license" file accompanying this file.  This file is distributed on an "AS
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

AWS_IAM_HOME=${AWS_IAM_HOME:-"/usr/lib/iamcli"}
[ -d "${AWS_IAM_HOME}/lib" ] && SERVICE_HOME="${AWS_IAM_HOME}/lib" ||
   SERVICE_HOME="${AWS_IAM_HOME}"
for j in "${SERVICE_HOME}"/*/*.jar; do cp="${cp:+${cp}:}${j}"; done

jshared=${AWS_IAM_JAVA_SHARED_CLASSPATH:-"/usr/share/java/log4j-1.2.jar:/usr/share/java/commons-codec.jar:/usr/share/java/httpclient.jar:/usr/share/java/httpcore.jar:/usr/share/java/commons-logging.jar:/usr/share/java/commons-logging-adapters.jar:/usr/share/java/commons-logging-api.jar"}
[ "${jshared#@@}" = "${jshared}" ] || jshared=""

exec java ${AWS_IAM_JVM_OPTS} -cp "${cp}${jshared:+:${jshared}}" \
com.amazonaws.services.auth.identity.cli.view.UserModView ${1+"$@"}
