#!/bin/bash
APP_HOME="/opt/conda/conda-bld/nf-test_1683962336803/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/share/nf-test-0.7.3-1"
APP_JAR="nf-test.jar"
APP_UPDATE_URL="https://code.askimed.com/install/nf-test"

set -e

FOLDER=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

update() {
  if command -v curl > /dev/null 2>&1; then
    curl -fsSL ${APP_UPDATE_URL} | bash
  else
    wget -qO- ${APP_UPDATE_URL} | bash
  fi
}

if test -f "${FOLDER}/${APP_JAR}"; then
  FILE_PATH_JAR=${FOLDER}/${APP_JAR}
else
  FILE_PATH_JAR=${APP_HOME}/${APP_JAR}
fi

export JAVA_PROGRAM_ARGS=`echo "$@"`

if [ "${JAVA_PROGRAM_ARGS}" = "update" ]; then
  echo "Updating application..."
  cd "${FOLDER}"
  update
else
  java -Xmx10G -jar "${FILE_PATH_JAR}" "$@"
fi
