From 2262f215a3efa2b286e89673bbcea7f1b0f56e5b Mon Sep 17 00:00:00 2001 From: binhex Date: Mon, 22 Jul 2024 22:58:35 +0100 Subject: [PATCH] add in java custom args --- README.md | 2 ++ build/root/install.sh | 7 +++++++ run/nobody/start.sh | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9558ba2..77d1dee 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ docker run -d \ -e JAVA_INITIAL_HEAP_SIZE= \ -e JAVA_MAX_HEAP_SIZE= \ -e JAVA_MAX_THREADS= \ + -e JAVA_CUSTOM_ARGS= \ -e STARTUP_CMD= \ -e UMASK= \ -e PUID= \ @@ -65,6 +66,7 @@ docker run -d \ -e JAVA_INITIAL_HEAP_SIZE=512M \ -e JAVA_MAX_HEAP_SIZE=1024M \ -e JAVA_MAX_THREADS=1 \ + -e JAVA_CUSTOM_ARGS='' \ -e STARTUP_CMD=gamerule reducedDebugInfo true \ -e UMASK=000 \ -e PUID=0 \ diff --git a/build/root/install.sh b/build/root/install.sh index b267dac..a379cec 100644 --- a/build/root/install.sh +++ b/build/root/install.sh @@ -273,6 +273,13 @@ else export JAVA_MAX_THREADS="1" fi +export JAVA_CUSTOM_ARGS=$(echo "${JAVA_CUSTOM_ARGS}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~') +if [[ ! -z "${JAVA_CUSTOM_ARGS}" ]]; then + echo "[info] JAVA_CUSTOM_ARGS defined as '${JAVA_CUSTOM_ARGS}'" | ts '%Y-%m-%d %H:%M:%.S' +else + echo "[info] JAVA_CUSTOM_ARGS not defined,(via -e JAVA_CUSTOM_ARGS)" | ts '%Y-%m-%d %H:%M:%.S' +fi + export STARTUP_CMD=$(echo "${STARTUP_CMD}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~') if [[ ! -z "${STARTUP_CMD}" ]]; then echo "[info] STARTUP_CMD defined as '${STARTUP_CMD}'" | ts '%Y-%m-%d %H:%M:%.S' diff --git a/run/nobody/start.sh b/run/nobody/start.sh index 531065c..e10aee1 100644 --- a/run/nobody/start.sh +++ b/run/nobody/start.sh @@ -121,7 +121,7 @@ function start_minecraft() { # run screen attached to minecraft (daemonized, non-blocking) to allow users to run commands in minecraft console echo "[info] Starting Minecraft Java process..." set -x - screen -L -Logfile '/config/minecraft/logs/screen.log' -d -S minecraft -m bash -c "cd /config/minecraft && java -Xms${JAVA_INITIAL_HEAP_SIZE} -Xmx${JAVA_MAX_HEAP_SIZE} -XX:ParallelGCThreads=${JAVA_MAX_THREADS} ${java_log4j_mitigation} -jar ${CUSTOM_JAR_PATH} nogui" + screen -L -Logfile '/config/minecraft/logs/screen.log' -d -S minecraft -m bash -c "cd /config/minecraft && java -Xms${JAVA_INITIAL_HEAP_SIZE} -Xmx${JAVA_MAX_HEAP_SIZE} -XX:ParallelGCThreads=${JAVA_MAX_THREADS} ${JAVA_CUSTOM_ARGS} ${java_log4j_mitigation} -jar ${CUSTOM_JAR_PATH} nogui" set +x echo "[info] Minecraft Java process is running" if [[ ! -z "${STARTUP_CMD}" ]]; then