#!/bin/sh
# CrossFTP Commander MCP (stdio). Requires Java 17+ at runtime.
# Usage: commander-mcp.sh --deployConfig /abs/path/to/crossftp-deploy.json [--configDir /abs/path/to/.crossftp]
# mcp/* must precede crossftp.jar (Jackson annotations 2.20 vs jar-embedded 2.6).
# All classpath entries use $DIR; client cwd is not required.
DIR="$(cd "$(dirname "$0")" && pwd)"

if [ -z "$JAVACMD" ] ; then
  if [ -n "$JAVA_HOME"  ] ; then
    JAVACMD="$JAVA_HOME/bin/java"
  else
    JAVACMD=`which java 2> /dev/null `
    if [ -z "$JAVACMD" ] ; then
        JAVACMD=java
    fi
  fi
fi

MCP_CP="$DIR/mcp/*:$DIR/crossftp.jar:$DIR/crossftp-resources.jar:$DIR/commons-logging.jar:$DIR/jnlp.jar:$DIR/looks-2.2.1.jar:$DIR/bcprov-jdk15on-147.jar:$DIR/guava-18.0.jar:$DIR/jclouds-blobstore-LATEST.jar:$DIR/jclouds-core-LATEST.jar:$DIR/azureblob-LATEST.jar:$DIR/openstack-swift-LATEST.jar:$DIR/openstack-keystone-LATEST.jar:$DIR/rackspace-cloudidentity-LATEST.jar"

exec "$JAVACMD" -cp "$MCP_CP" crossftp.mcp.CommanderMcpMain "$@"
