#!/bin/sh

if [ "x$JAVA_HOME" != "x" ]; then
    JAVA="$JAVA_HOME/bin/java"
else
    JAVA="java"
fi

# -Xss256k: thread stack size. 256K reduces per-thread memory usage and may prevent "java.lang.OutOfMemoryError: unable to create new native thread" on some systems
# -Djava.awt.headless=true: required for image transcoding to work on headless systems (eg no X-Window libraries)

# Required for openSUSE's OpenJDK to not fail on TLS connections for the connectivity test. These properties do nothing on other distros:
# -Djava.security.disableSystemPropertiesFile=true: OpenJDK < 25
# -Dsystem.crypto-policies=false: OpenJDK >= 25

JVM_ARGS="-Xss256k -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Dsystem.crypto-policies=false -Djava.security.disableSystemPropertiesFile=true -Dslf4j.internal.report.stream=stdout -Dslf4j.internal.verbosity=WARN"

exec "$JAVA" $JVM_ARGS $USER_JVM_ARGS -jar BubbleUPnPTetherClient.jar "$@"
