#!/bin/sh

PREFIX=`dirname $0`

LIBDIR=$PREFIX/lib
CLIDIR=$PREFIX/cli
THIRDPARTY=$PREFIX/third-party
HTTPCLIENT=$THIRDPARTY/httpcomponents-client
COMMONSLOGGING=$THIRDPARTY/commons-logging
LOG4J=$THIRDPARTY/log4j
JSONIC=$THIRDPARTY/jsonic
AWSV4SIGNER=$THIRDPARTY/aws-v4-signer-java

CLASSPATH=$CLASSPATH:$COMMONSLOGGING/commons-logging-1.2.jar
CLASSPATH=$CLASSPATH:$LOG4J/log4j-1.2.17.jar
CLASSPATH=$CLASSPATH:$HTTPCLIENT/commons-codec-1.15.jar
CLASSPATH=$CLASSPATH:$HTTPCLIENT/httpcore-4.4.15.jar
CLASSPATH=$CLASSPATH:$HTTPCLIENT/httpmime-4.5.13.jar
CLASSPATH=$CLASSPATH:$HTTPCLIENT/httpclient-4.5.13.jar
CLASSPATH=$CLASSPATH:$HTTPCLIENT/httpclient-cache-4.5.13.jar
CLASSPATH=$CLASSPATH:$JSONIC/jsonic-1.2.11.jar
CLASSPATH=$CLASSPATH:$LIBDIR/nifcloud-storage-sdk-1.5.jar
CLASSPATH=$CLASSPATH:$CLIDIR/nifcloud-storage-cli-1.5.jar
CLASSPATH=$CLASSPATH:$AWSV4SIGNER/aws-v4-signer-java-1.3.jar
CLASSPATH=$CLASSPATH:$PREFIX/cli


# endpoint settings
#ENDPOINT="-Dendpoint=https://jp-east-1.storage.api.nifcloud.com/"

# proxy settings
#PROXY_HOST="-Dhttp.proxyHost=host"
#PROXY_PORT="-Dhttp.proxyPort=port"
#PROXY_USER="-Dhttp.proxyUser=user"
#PROXY_PASS="-Dhttp.proxyPass=pass"

# retry settings
#MAX_RETRY="-Dhttp.maxRetry=retry"

# multipart settings
#MAX_THREADS="-Dmultipart.maxThreads=maxThreads"
#MULTIPART_THRESHOLD="-Dmultipart.threshold=threshold"
#MULTIPART_PART_SIZE="-Dmultipart.partSize=partSize"
#MULTIPART_MAX_SIZE="-Dmultipart.maxSize=5368709120"

java -classpath $CLASSPATH $ENDPOINT\
 $PROXY_HOST $PROXY_PORT $PROXY_USER $PROXY_PASS\
 $MAX_THREADS $MULTIPART_THRESHOLD $MULTIPART_PART_SIZE $MULTIPART_MAX_SIZE\
 $MAX_RETRY\
 com.nifty.cloud.ncs.service.cli.CommandLineInterface $@

exit $?
