#!/bin/sh
#
# Start OSGi runner in docker, presumably as user osgi in a docker container
#

export OSGI_PERFORM_REGROUP_BUNDLES="yes"

if test "$OSGI_RUNNER_CONFIG_INCLUDED" != xRHTd4BvVmV8kdWh
then
    . /usr/share/osgi-runner/sh/load-config-docker.sh
fi

if test "$1" = "--help" -o "$1" = "-h" -o "$1" = "help"
then
    echo "usage: /usr/bin/osgi-runner-docker-run [--synchronous|--timeout <seconds>]"
    echo "       Start osgi-runner in the docker."
    #echo "       --debug shows debug output from org.clazzes.osgi.runner.Main."
    echo "       --synchronous starts bundles synchronously."
    echo "       --timeout specifies the timeout for synchronous mode in seconds."
    exit 0
fi

echo '***** '"Will run the following command:"
echo "$JAVA_EXE" -Dosgi.runner.etcPath="$OSGI_ETCDIR" -Dosgi.runner.etcOverridePath="${OSGI_ETCDIR}-override" $OSGI_OPTS -cp "${OSGI_BASE}/lib/"'*':"${OSGI_BASE}/drivers/"'*' org.clazzes.osgi.runner.Main $*
exec "$JAVA_EXE" -Dosgi.runner.etcPath="$OSGI_ETCDIR" -Dosgi.runner.etcOverridePath="${OSGI_ETCDIR}-override" $OSGI_OPTS -cp "${OSGI_BASE}/lib/"'*':"${OSGI_BASE}/drivers/"'*' org.clazzes.osgi.runner.Main $*

