mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-11-04 15:59:27 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0559797542 | ||
|
|
0e124927f7 | ||
|
|
3d43aea36b | ||
|
|
926a34b885 | ||
|
|
88cc9d112a | ||
|
|
795d2aee38 | ||
|
|
4b75711f37 | ||
|
|
5692cf852e | ||
|
|
c5d913ad5e | ||
|
|
4197034221 | ||
|
|
2e04d8c973 | ||
|
|
e4a381805e |
No files matched your search
@@ -193,14 +193,14 @@ jobs:
|
|||||||
tests/test.sh
|
tests/test.sh
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v4.6.0
|
uses: docker/login-action@v4.7.0
|
||||||
if: env.HAS_IMAGE_REPO_ACCESS == 'true'
|
if: env.HAS_IMAGE_REPO_ACCESS == 'true'
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USER }}
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
uses: docker/login-action@v4.6.0
|
uses: docker/login-action@v4.7.0
|
||||||
if: env.HAS_IMAGE_REPO_ACCESS == 'true'
|
if: env.HAS_IMAGE_REPO_ACCESS == 'true'
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
|||||||
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
# renovate: datasource=github-releases packageName=itzg/mc-image-helper versioning=loose
|
# renovate: datasource=github-releases packageName=itzg/mc-image-helper versioning=loose
|
||||||
ARG MC_HELPER_VERSION=1.74.2
|
ARG MC_HELPER_VERSION=1.75.0
|
||||||
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
||||||
# used for cache busting local copy of mc-image-helper
|
# used for cache busting local copy of mc-image-helper
|
||||||
ARG MC_HELPER_REV=1
|
ARG MC_HELPER_REV=1
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
[The MASH Playbook](https://github.com/mother-of-all-self-hosting/mash-playbook) is a premade playbook with the option to deploy a [wide variety of open-source services](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/supported-services.md) to your server(s), including [docker-minecraft-server](https://github.com/mother-of-all-self-hosting/ansible-role-minecraft), making it a good option if you want all the bells and whistles alongside your Minecraft server.
|
[The MASH Playbook](https://github.com/mother-of-all-self-hosting/mash-playbook) is a premade playbook with the option to deploy a [wide variety of open-source services](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/supported-services.md) to your server(s), including [docker-minecraft-server](https://github.com/mother-of-all-self-hosting/ansible-role-minecraft), making it a good option if you want all the bells and whistles alongside your Minecraft server.
|
||||||
- Check out the [Installation Guide](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/README.md) for the MASH playbook to get started.
|
- Check out the [Installation Guide](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/README.md) for the MASH playbook to get started.
|
||||||
- You can then enable [Minecraft](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/minecraft.md) in your vars.yml.
|
- You can then enable [Minecraft](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/minecraft/README.md) in your vars.yml.
|
||||||
- Enable any supporting services that you might find useful, such as [user authentication](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/authelia.md), [remote backups](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/backup-borg.md), [email relay](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/exim-relay.md), [cron monitoring](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/healthchecks.md), [audio and video conferencing](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/jitsi.md), databases ([MariaDB](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/mariadb.md), [PostgresSQL](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/postgres.md)), [push notifications](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/ntfy.md), [uptime monitoring](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/uptime-kuma.md), [a website](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/wordpress.md), as well as installing any [extra files, folders, applications, services and running commands](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/docs/services/auxiliary.md) automatically on deployment.
|
- Enable any supporting services that you might find useful, such as [user authentication](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/authelia/README.md), [remote backups](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/backup_borg/README.md), [email relay](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/exim_relay/README.md), [cron monitoring](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/healthchecks/README.md), [audio and video conferencing](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/jitsi/README.md), databases ([MariaDB](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/mariadb/README.md), [PostgresSQL](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/postgres/README.md)), [push notifications](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/ntfy/README.md), [uptime monitoring](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/uptime_kuma/README.md), [a website](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/wordpress/README.md), as well as installing any [extra files, folders, applications, services and running commands](https://github.com/mother-of-all-self-hosting/mash-playbook/blob/main/components/auxiliary/README.md) automatically on deployment.
|
||||||
|
|
||||||
## On CloudFormation (AWS)
|
## On CloudFormation (AWS)
|
||||||
|
|
||||||
|
|||||||
@@ -2,24 +2,24 @@ click==8.5.0
|
|||||||
colorama==0.4.6
|
colorama==0.4.6
|
||||||
deepmerge==3.0.1
|
deepmerge==3.0.1
|
||||||
ghp-import==2.1.0
|
ghp-import==2.1.0
|
||||||
griffe==2.3.2
|
griffe==2.4.1
|
||||||
Jinja2==3.1.6
|
Jinja2==3.1.6
|
||||||
Markdown==3.11.1
|
Markdown==3.11.2
|
||||||
MarkupSafe==3.0.4
|
MarkupSafe==3.0.4
|
||||||
mergedeep==1.3.4
|
mergedeep==1.3.4
|
||||||
mkdocs==1.6.1
|
mkdocs==1.6.1
|
||||||
mkdocs-autorefs==1.4.4
|
mkdocs-autorefs==1.4.5
|
||||||
mkdocs-get-deps==0.2.2
|
mkdocs-get-deps==0.2.2
|
||||||
mkdocstrings==1.0.7
|
mkdocstrings==1.0.8
|
||||||
mkdocstrings-python==2.0.9
|
mkdocstrings-python==2.0.10
|
||||||
packaging==26.3
|
packaging==26.3
|
||||||
pathspec==1.1.1
|
pathspec==1.1.1
|
||||||
platformdirs==4.13.4
|
platformdirs==4.14.2
|
||||||
Pygments==2.21.0
|
Pygments==2.21.0
|
||||||
pymdown-extensions==12.3
|
pymdown-extensions==12.3
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==4.0.0
|
||||||
PyYAML==6.0.3
|
PyYAML==6.0.3
|
||||||
pyyaml_env_tag==1.1
|
pyyaml_env_tag==1.1
|
||||||
six==1.17.0
|
six==1.17.0
|
||||||
watchdog==6.0.0
|
watchdog==6.0.0
|
||||||
zensical==0.0.71
|
zensical==0.0.74
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
services:
|
||||||
|
minecraft:
|
||||||
|
image: itzg/minecraft-server:java25
|
||||||
|
tty: true
|
||||||
|
stdin_open: true
|
||||||
|
ports:
|
||||||
|
- "25565:25565"
|
||||||
|
environment:
|
||||||
|
EULA: true
|
||||||
|
MOD_PLATFORM: AUTO_CURSEFORGE
|
||||||
|
CF_SLUG: "custom"
|
||||||
|
CF_MODPACK_ZIP: "/downloads/modpacks/PO3-3.5.1.zip"
|
||||||
|
APPLY_CLEANROOM: true
|
||||||
|
# Mod needed for this pack
|
||||||
|
CF_FORCE_INCLUDE_MODS: hwyla
|
||||||
|
MEMORY: 8G
|
||||||
|
OVERRIDE_SERVER_PROPERTIES: true
|
||||||
|
LEVEL_TYPE: botania-skyblock
|
||||||
|
volumes:
|
||||||
|
- ./downloads:/downloads
|
||||||
|
- ./data:/data
|
||||||
|
# Uses managed volume by default
|
||||||
|
#- mc-data:/data
|
||||||
|
|
||||||
|
# Managed volume by default
|
||||||
|
#volumes:
|
||||||
|
#mc-data:
|
||||||
@@ -181,6 +181,9 @@
|
|||||||
"all-of-fabric-6": {
|
"all-of-fabric-6": {
|
||||||
"forceIncludes": ["revelationary"]
|
"forceIncludes": ["revelationary"]
|
||||||
},
|
},
|
||||||
|
"better-mc-forge-bmc4": {
|
||||||
|
"forceIncludes": ["wakes-reforged"]
|
||||||
|
},
|
||||||
"beyond-depth": {
|
"beyond-depth": {
|
||||||
"forceIncludes": ["particular-reforged"]
|
"forceIncludes": ["particular-reforged"]
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-333
@@ -65,66 +65,11 @@ if [ -n "$ICON" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
useGeneratedLogs=${GENERATE_LOG4J2_CONFIG:-${ENABLE_ROLLING_LOGS:-false}}
|
|
||||||
useFallbackJvmFlag=false
|
|
||||||
|
|
||||||
SERVER_DIR="$baseDataDir"
|
SERVER_DIR="$baseDataDir"
|
||||||
if [[ ${FTB_DIR:-} ]]; then
|
if [[ ${FTB_DIR:-} ]]; then
|
||||||
SERVER_DIR="$FTB_DIR"
|
SERVER_DIR="$FTB_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
patchLog4jConfig() {
|
|
||||||
file=${1?}
|
|
||||||
url=${2?}
|
|
||||||
if ! get -o "${SERVER_DIR}/${file}" "$url"; then
|
|
||||||
logError "Failed to download corrected log4j config, fallback to JVM flag"
|
|
||||||
useFallbackJvmFlag=true
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
JVM_OPTS="-Dlog4j.configurationFile=${file} ${JVM_OPTS}"
|
|
||||||
useGeneratedLogs=false
|
|
||||||
}
|
|
||||||
|
|
||||||
# Temporarily disable debugging output
|
|
||||||
oldState=$(shopt -po xtrace || true)
|
|
||||||
shopt -u -o xtrace
|
|
||||||
# Patch Log4j remote code execution vulnerability
|
|
||||||
# See https://www.minecraft.net/en-us/article/important-message--security-vulnerability-java-edition
|
|
||||||
if isFamily NATIVE; then
|
|
||||||
: # Native server, so there is no log4j to patch
|
|
||||||
elif versionLessThan 1.7; then
|
|
||||||
: # No patch required here.
|
|
||||||
elif isFamily VANILLA && versionLessThan 1.12; then
|
|
||||||
patchLog4jConfig log4j2_17-111.xml https://launcher.mojang.com/v1/objects/dd2b723346a8dcd48e7f4d245f6bf09e98db9696/log4j2_17-111.xml
|
|
||||||
elif isFamily VANILLA && versionLessThan 1.17; then
|
|
||||||
patchLog4jConfig log4j2_112-116.xml https://launcher.mojang.com/v1/objects/02937d122c86ce73319ef9975b58896fc1b491d1/log4j2_112-116.xml
|
|
||||||
# See https://purpurmc.org/docs/Log4j/
|
|
||||||
elif isType PURPUR && versionLessThan 1.17; then
|
|
||||||
patchLog4jConfig purpur_log4j2_1141-1165.xml https://purpurmc.org/docs/xml/purpur_log4j2_1141-1165.xml
|
|
||||||
elif isType PURPUR && versionLessThan 1.18.1; then
|
|
||||||
patchLog4jConfig purpur_log4j2_117.xml https://purpurmc.org/docs/xml/purpur_log4j2_117.xml
|
|
||||||
elif versionLessThan 1.18.1; then
|
|
||||||
useFallbackJvmFlag=true
|
|
||||||
fi
|
|
||||||
eval "$oldState"
|
|
||||||
|
|
||||||
if ${useFallbackJvmFlag}; then
|
|
||||||
JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true ${JVM_OPTS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isFamily NATIVE; then
|
|
||||||
: # Native server, so no Log4jPatcher agent
|
|
||||||
elif versionLessThan 1.7; then
|
|
||||||
: # No patch required here.
|
|
||||||
elif versionLessThan 1.18.1; then
|
|
||||||
if isTrue "${SKIP_LOG4J_PATCHER:-false}"; then
|
|
||||||
log "Skipping Log4jPatcher, make sure you are not affected"
|
|
||||||
else
|
|
||||||
JVM_OPTS="-javaagent:/image/Log4jPatcher.jar ${JVM_OPTS}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
function addAgents() {
|
function addAgents() {
|
||||||
local agents=$1 outDir=$2 glob=$3 option=$4
|
local agents=$1 outDir=$2 glob=$3 option=$4
|
||||||
|
|
||||||
@@ -158,80 +103,8 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up log4j2 configuration with templating support
|
# shellcheck source=start-finalExec-log4j
|
||||||
LOGFILE="${SERVER_DIR}/log4j2.xml"
|
. "$(dirname "$0")/start-finalExec-log4j"
|
||||||
if isFamily NATIVE; then
|
|
||||||
: # Native server, so no log4j configuration
|
|
||||||
elif ${useGeneratedLogs}; then
|
|
||||||
# Set up log configuration defaults
|
|
||||||
: "${LOG_LEVEL:=info}"
|
|
||||||
: "${ROLLING_LOG_MAX_FILES:=1000}"
|
|
||||||
# Note: Can't use ${VAR:=default} syntax for values containing } as it breaks parsing
|
|
||||||
if [ -z "${ROLLING_LOG_FILE_PATTERN}" ]; then
|
|
||||||
ROLLING_LOG_FILE_PATTERN='logs/%d{yyyy-MM-dd}-%i.log.gz'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pattern format defaults (compatible with vanilla Minecraft)
|
|
||||||
# Note: Can't use ${VAR:=default} syntax because } in the value breaks parsing
|
|
||||||
if [ -z "${LOG_CONSOLE_FORMAT}" ]; then
|
|
||||||
LOG_CONSOLE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
|
||||||
fi
|
|
||||||
if [ -z "${LOG_TERMINAL_FORMAT}" ]; then
|
|
||||||
LOG_TERMINAL_FORMAT='[%d{HH:mm:ss} %level]: %msg%n'
|
|
||||||
fi
|
|
||||||
if [ -z "${LOG_FILE_FORMAT}" ]; then
|
|
||||||
LOG_FILE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
|
||||||
fi
|
|
||||||
|
|
||||||
export LOG_LEVEL ROLLING_LOG_FILE_PATTERN ROLLING_LOG_MAX_FILES
|
|
||||||
export LOG_CONSOLE_FORMAT LOG_TERMINAL_FORMAT LOG_FILE_FORMAT
|
|
||||||
|
|
||||||
|
|
||||||
# Always regenerate if file doesn't exist
|
|
||||||
if [ ! -e "$LOGFILE" ] || isTrue "${REGENERATE_LOG4J2:-true}"; then
|
|
||||||
log "Generating log4j2.xml from template in ${LOGFILE}"
|
|
||||||
|
|
||||||
# Generate log4j2.xml using heredoc for reliable variable substitution
|
|
||||||
cat > "$LOGFILE" <<EOF
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Configuration status="WARN">
|
|
||||||
<Appenders>
|
|
||||||
<Console name="SysOut" target="SYSTEM_OUT">
|
|
||||||
<PatternLayout pattern="${LOG_CONSOLE_FORMAT}" />
|
|
||||||
</Console>
|
|
||||||
<Queue name="TerminalConsole">
|
|
||||||
<PatternLayout pattern="${LOG_TERMINAL_FORMAT}" />
|
|
||||||
</Queue>
|
|
||||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="${ROLLING_LOG_FILE_PATTERN}">
|
|
||||||
<PatternLayout pattern="${LOG_FILE_FORMAT}" />
|
|
||||||
<Policies>
|
|
||||||
<TimeBasedTriggeringPolicy />
|
|
||||||
<OnStartupTriggeringPolicy />
|
|
||||||
</Policies>
|
|
||||||
<DefaultRolloverStrategy max="${ROLLING_LOG_MAX_FILES}"/>
|
|
||||||
</RollingRandomAccessFile>
|
|
||||||
</Appenders>
|
|
||||||
<Loggers>
|
|
||||||
<Root level="${LOG_LEVEL}">
|
|
||||||
<filters>
|
|
||||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
|
||||||
</filters>
|
|
||||||
<AppenderRef ref="SysOut"/>
|
|
||||||
<AppenderRef ref="File"/>
|
|
||||||
<AppenderRef ref="TerminalConsole"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
|
||||||
</Configuration>
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
log "log4j2.xml already exists and is up to date, skipping generation"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Apply the log4j2 configuration
|
|
||||||
JVM_OPTS="-Dlog4j.configurationFile=log4j2.xml ${JVM_OPTS}"
|
|
||||||
else
|
|
||||||
rm -f "${LOGFILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Optional disable console
|
# Optional disable console
|
||||||
if ! isFamily NATIVE && versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
|
if ! isFamily NATIVE && versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
|
||||||
@@ -265,210 +138,8 @@ if isTrue "${ENABLE_JMX}"; then
|
|||||||
log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}"
|
log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: "${USE_AIKAR_FLAGS:=false}"
|
# shellcheck source=start-finalExec-jvmFlags
|
||||||
: "${USE_MEOWICE_FLAGS:=false}"
|
. "$(dirname "$0")/start-finalExec-jvmFlags"
|
||||||
: "${USE_MEOWICE_GRAALVM_FLAGS:=false}"
|
|
||||||
|
|
||||||
if isTrue "${USE_MEOWICE_FLAGS}" || isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then
|
|
||||||
java_major_version=$(mc-image-helper java-release)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
|
||||||
if [[ $java_major_version -gt 16 ]]; then
|
|
||||||
log "Java version $java_major_version using MeowIce's flags for Java 17+"
|
|
||||||
else
|
|
||||||
log "Your Java version is $java_major_version, MeowIce's flags are for Java 17+ falling back to Aikar's"
|
|
||||||
USE_MEOWICE_FLAGS=FALSE
|
|
||||||
USE_AIKAR_FLAGS=TRUE
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_AIKAR_FLAGS}" || isTrue "${USE_MEOWICE_FLAGS}"; then
|
|
||||||
# From https://mcflags.emc.gs/
|
|
||||||
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
|
||||||
log "Using MeowIce's flags"
|
|
||||||
G1NewSizePercent=28
|
|
||||||
G1MaxNewSizePercent=50
|
|
||||||
G1HeapRegionSize=16M
|
|
||||||
G1ReservePercent=15
|
|
||||||
InitiatingHeapOccupancyPercent=20
|
|
||||||
G1MixedGCCountTarget=3
|
|
||||||
G1RSetUpdatingPauseTimePercent=0
|
|
||||||
elif [[ $MAX_MEMORY ]] && (( $(normalizeMemSize "${MAX_MEMORY}") >= $(normalizeMemSize 12g) )); then
|
|
||||||
log "Using Aikar's >12GB flags"
|
|
||||||
G1NewSizePercent=40
|
|
||||||
G1MaxNewSizePercent=50
|
|
||||||
G1HeapRegionSize=16M
|
|
||||||
G1ReservePercent=15
|
|
||||||
InitiatingHeapOccupancyPercent=20
|
|
||||||
G1MixedGCCountTarget=4
|
|
||||||
G1RSetUpdatingPauseTimePercent=5
|
|
||||||
else
|
|
||||||
log "Using Aikar's flags"
|
|
||||||
G1NewSizePercent=30
|
|
||||||
G1MaxNewSizePercent=40
|
|
||||||
G1HeapRegionSize=8M
|
|
||||||
G1ReservePercent=20
|
|
||||||
InitiatingHeapOccupancyPercent=15
|
|
||||||
G1MixedGCCountTarget=4
|
|
||||||
G1RSetUpdatingPauseTimePercent=5
|
|
||||||
fi
|
|
||||||
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UseG1GC
|
|
||||||
-XX:+ParallelRefProcEnabled
|
|
||||||
-XX:MaxGCPauseMillis=200
|
|
||||||
-XX:+UnlockExperimentalVMOptions
|
|
||||||
-XX:+DisableExplicitGC
|
|
||||||
-XX:+AlwaysPreTouch
|
|
||||||
-XX:G1NewSizePercent=${G1NewSizePercent}
|
|
||||||
-XX:G1MaxNewSizePercent=${G1MaxNewSizePercent}
|
|
||||||
-XX:G1HeapRegionSize=${G1HeapRegionSize}
|
|
||||||
-XX:G1ReservePercent=${G1ReservePercent}
|
|
||||||
-XX:G1HeapWastePercent=5
|
|
||||||
-XX:G1MixedGCCountTarget=${G1MixedGCCountTarget}
|
|
||||||
-XX:InitiatingHeapOccupancyPercent=${InitiatingHeapOccupancyPercent}
|
|
||||||
-XX:G1MixedGCLiveThresholdPercent=90
|
|
||||||
-XX:G1RSetUpdatingPauseTimePercent=${G1RSetUpdatingPauseTimePercent}
|
|
||||||
-XX:SurvivorRatio=32
|
|
||||||
-XX:+PerfDisableSharedMem
|
|
||||||
-XX:MaxTenuringThreshold=1
|
|
||||||
"
|
|
||||||
if isTrue "${USE_AIKAR_FLAGS}"; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-Dusing.aikars.flags=https://mcflags.emc.gs
|
|
||||||
-Daikars.new.flags=true
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UnlockDiagnosticVMOptions
|
|
||||||
-XX:+UnlockExperimentalVMOptions
|
|
||||||
-XX:G1SATBBufferEnqueueingThresholdPercent=30
|
|
||||||
-XX:G1ConcMarkStepDurationMillis=5
|
|
||||||
-XX:+UseNUMA
|
|
||||||
-XX:-DontCompileHugeMethods
|
|
||||||
-XX:MaxNodeLimit=240000
|
|
||||||
-XX:NodeLimitFudgeFactor=8000
|
|
||||||
-XX:ReservedCodeCacheSize=400M
|
|
||||||
-XX:NonNMethodCodeHeapSize=12M
|
|
||||||
-XX:ProfiledCodeHeapSize=194M
|
|
||||||
-XX:NonProfiledCodeHeapSize=194M
|
|
||||||
-XX:NmethodSweepActivity=1
|
|
||||||
-XX:+UseFastUnorderedTimeStamps
|
|
||||||
-XX:+UseCriticalJavaThreadPriority
|
|
||||||
-XX:AllocatePrefetchStyle=3
|
|
||||||
-XX:+AlwaysActAsServerClassMachine
|
|
||||||
-XX:+UseTransparentHugePages
|
|
||||||
-XX:LargePageSizeInBytes=2M
|
|
||||||
-XX:+UseLargePages
|
|
||||||
-XX:+EagerJVMCI
|
|
||||||
-XX:+UseStringDeduplication
|
|
||||||
-XX:+UseAES
|
|
||||||
-XX:+UseAESIntrinsics
|
|
||||||
-XX:+UseFMA
|
|
||||||
-XX:+UseLoopPredicate
|
|
||||||
-XX:+RangeCheckElimination
|
|
||||||
-XX:+OptimizeStringConcat
|
|
||||||
-XX:+UseCompressedOops
|
|
||||||
-XX:+UseThreadPriorities
|
|
||||||
-XX:+OmitStackTraceInFastThrow
|
|
||||||
-XX:+RewriteBytecodes
|
|
||||||
-XX:+RewriteFrequentPairs
|
|
||||||
-XX:+UseFPUForSpilling
|
|
||||||
-XX:+UseVectorCmov
|
|
||||||
-XX:+UseXMMForArrayCopy
|
|
||||||
-XX:+EliminateLocks
|
|
||||||
-XX:+DoEscapeAnalysis
|
|
||||||
-XX:+AlignVector
|
|
||||||
-XX:+OptimizeFill
|
|
||||||
-XX:+EnableVectorSupport
|
|
||||||
-XX:+UseCharacterCompareIntrinsics
|
|
||||||
-XX:+UseCopySignIntrinsic
|
|
||||||
-XX:+UseVectorStubs
|
|
||||||
"
|
|
||||||
if [[ $(arch) == "x86_64" ]]; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UseFastStosb
|
|
||||||
-XX:+UseNewLongLShift
|
|
||||||
-XX:+UseXmmI2D
|
|
||||||
-XX:+UseXmmI2F
|
|
||||||
-XX:+UseXmmLoadAndClearUpper
|
|
||||||
-XX:+UseXmmRegToRegMoveAll
|
|
||||||
-XX:UseAVX=2
|
|
||||||
-XX:UseSSE=4
|
|
||||||
"
|
|
||||||
else
|
|
||||||
log "cpu not x86_64, disabling architecture specific flags"
|
|
||||||
fi
|
|
||||||
if [[ $java_major_version -gt 23 ]]; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UseCompactObjectHeaders
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then
|
|
||||||
if [[ $java_major_version -gt 23 ]]; then
|
|
||||||
log "Java 24 or higher detected, using modified GraalVM flags"
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UseFastJNIAccessors
|
|
||||||
-XX:+UseInlineCaches
|
|
||||||
-XX:+SegmentedCodeCache
|
|
||||||
-Djdk.nio.maxCachedBufferSize=262144
|
|
||||||
-Djdk.graal.UsePriorityInlining=true
|
|
||||||
-Djdk.graal.Vectorization=true
|
|
||||||
-Djdk.graal.OptDuplication=true
|
|
||||||
-Djdk.graal.DetectInvertedLoopsAsCounted=true
|
|
||||||
-Djdk.graal.LoopInversion=true
|
|
||||||
-Djdk.graal.VectorizeHashes=true
|
|
||||||
-Djdk.graal.EnterprisePartialUnroll=true
|
|
||||||
-Djdk.graal.VectorizeSIMD=true
|
|
||||||
-Djdk.graal.StripMineNonCountedLoops=true
|
|
||||||
-Djdk.graal.SpeculativeGuardMovement=true
|
|
||||||
-Djdk.graal.TuneInlinerExploration=1
|
|
||||||
-Djdk.graal.LoopRotation=true
|
|
||||||
-Djdk.graal.CompilerConfiguration=enterprise
|
|
||||||
"
|
|
||||||
else
|
|
||||||
log "Using MeowIce's flags for Graalvm"
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UseFastJNIAccessors
|
|
||||||
-XX:+UseInlineCaches
|
|
||||||
-XX:+SegmentedCodeCache
|
|
||||||
-Djdk.nio.maxCachedBufferSize=262144
|
|
||||||
-Dgraal.UsePriorityInlining=true
|
|
||||||
-Dgraal.Vectorization=true
|
|
||||||
-Dgraal.OptDuplication=true
|
|
||||||
-Dgraal.DetectInvertedLoopsAsCounted=true
|
|
||||||
-Dgraal.LoopInversion=true
|
|
||||||
-Dgraal.VectorizeHashes=true
|
|
||||||
-Dgraal.EnterprisePartialUnroll=true
|
|
||||||
-Dgraal.VectorizeSIMD=true
|
|
||||||
-Dgraal.StripMineNonCountedLoops=true
|
|
||||||
-Dgraal.SpeculativeGuardMovement=true
|
|
||||||
-Dgraal.TuneInlinerExploration=1
|
|
||||||
-Dgraal.LoopRotation=true
|
|
||||||
-Dgraal.OptWriteMotion=true
|
|
||||||
-Dgraal.CompilerConfiguration=enterprise
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_FLARE_FLAGS}"; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
-XX:+UnlockDiagnosticVMOptions
|
|
||||||
-XX:+DebugNonSafepoints
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isTrue "${USE_SIMD_FLAGS}"; then
|
|
||||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
|
||||||
--add-modules=jdk.incubator.vector
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Handle GTNH args
|
# Handle GTNH args
|
||||||
if isType "GTNH"; then
|
if isType "GTNH"; then
|
||||||
|
|||||||
Executable
+206
@@ -0,0 +1,206 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
: "${USE_AIKAR_FLAGS:=false}"
|
||||||
|
: "${USE_MEOWICE_FLAGS:=false}"
|
||||||
|
: "${USE_MEOWICE_GRAALVM_FLAGS:=false}"
|
||||||
|
|
||||||
|
if isTrue "${USE_MEOWICE_FLAGS}" || isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then
|
||||||
|
java_major_version=$(mc-image-helper java-release)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||||
|
if [[ $java_major_version -gt 16 ]]; then
|
||||||
|
log "Java version $java_major_version using MeowIce's flags for Java 17+"
|
||||||
|
else
|
||||||
|
log "Your Java version is $java_major_version, MeowIce's flags are for Java 17+ falling back to Aikar's"
|
||||||
|
USE_MEOWICE_FLAGS=FALSE
|
||||||
|
USE_AIKAR_FLAGS=TRUE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_AIKAR_FLAGS}" || isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||||
|
# From https://mcflags.emc.gs/
|
||||||
|
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||||
|
log "Using MeowIce's flags"
|
||||||
|
G1NewSizePercent=28
|
||||||
|
G1MaxNewSizePercent=50
|
||||||
|
G1HeapRegionSize=16M
|
||||||
|
G1ReservePercent=15
|
||||||
|
InitiatingHeapOccupancyPercent=20
|
||||||
|
G1MixedGCCountTarget=3
|
||||||
|
G1RSetUpdatingPauseTimePercent=0
|
||||||
|
elif [[ $MAX_MEMORY ]] && (( $(normalizeMemSize "${MAX_MEMORY}") >= $(normalizeMemSize 12g) )); then
|
||||||
|
log "Using Aikar's >12GB flags"
|
||||||
|
G1NewSizePercent=40
|
||||||
|
G1MaxNewSizePercent=50
|
||||||
|
G1HeapRegionSize=16M
|
||||||
|
G1ReservePercent=15
|
||||||
|
InitiatingHeapOccupancyPercent=20
|
||||||
|
G1MixedGCCountTarget=4
|
||||||
|
G1RSetUpdatingPauseTimePercent=5
|
||||||
|
else
|
||||||
|
log "Using Aikar's flags"
|
||||||
|
G1NewSizePercent=30
|
||||||
|
G1MaxNewSizePercent=40
|
||||||
|
G1HeapRegionSize=8M
|
||||||
|
G1ReservePercent=20
|
||||||
|
InitiatingHeapOccupancyPercent=15
|
||||||
|
G1MixedGCCountTarget=4
|
||||||
|
G1RSetUpdatingPauseTimePercent=5
|
||||||
|
fi
|
||||||
|
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UseG1GC
|
||||||
|
-XX:+ParallelRefProcEnabled
|
||||||
|
-XX:MaxGCPauseMillis=200
|
||||||
|
-XX:+UnlockExperimentalVMOptions
|
||||||
|
-XX:+DisableExplicitGC
|
||||||
|
-XX:+AlwaysPreTouch
|
||||||
|
-XX:G1NewSizePercent=${G1NewSizePercent}
|
||||||
|
-XX:G1MaxNewSizePercent=${G1MaxNewSizePercent}
|
||||||
|
-XX:G1HeapRegionSize=${G1HeapRegionSize}
|
||||||
|
-XX:G1ReservePercent=${G1ReservePercent}
|
||||||
|
-XX:G1HeapWastePercent=5
|
||||||
|
-XX:G1MixedGCCountTarget=${G1MixedGCCountTarget}
|
||||||
|
-XX:InitiatingHeapOccupancyPercent=${InitiatingHeapOccupancyPercent}
|
||||||
|
-XX:G1MixedGCLiveThresholdPercent=90
|
||||||
|
-XX:G1RSetUpdatingPauseTimePercent=${G1RSetUpdatingPauseTimePercent}
|
||||||
|
-XX:SurvivorRatio=32
|
||||||
|
-XX:+PerfDisableSharedMem
|
||||||
|
-XX:MaxTenuringThreshold=1
|
||||||
|
"
|
||||||
|
if isTrue "${USE_AIKAR_FLAGS}"; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-Dusing.aikars.flags=https://mcflags.emc.gs
|
||||||
|
-Daikars.new.flags=true
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UnlockDiagnosticVMOptions
|
||||||
|
-XX:+UnlockExperimentalVMOptions
|
||||||
|
-XX:G1SATBBufferEnqueueingThresholdPercent=30
|
||||||
|
-XX:G1ConcMarkStepDurationMillis=5
|
||||||
|
-XX:+UseNUMA
|
||||||
|
-XX:-DontCompileHugeMethods
|
||||||
|
-XX:MaxNodeLimit=240000
|
||||||
|
-XX:NodeLimitFudgeFactor=8000
|
||||||
|
-XX:ReservedCodeCacheSize=400M
|
||||||
|
-XX:NonNMethodCodeHeapSize=12M
|
||||||
|
-XX:ProfiledCodeHeapSize=194M
|
||||||
|
-XX:NonProfiledCodeHeapSize=194M
|
||||||
|
-XX:NmethodSweepActivity=1
|
||||||
|
-XX:+UseFastUnorderedTimeStamps
|
||||||
|
-XX:+UseCriticalJavaThreadPriority
|
||||||
|
-XX:AllocatePrefetchStyle=3
|
||||||
|
-XX:+AlwaysActAsServerClassMachine
|
||||||
|
-XX:+UseTransparentHugePages
|
||||||
|
-XX:LargePageSizeInBytes=2M
|
||||||
|
-XX:+UseLargePages
|
||||||
|
-XX:+EagerJVMCI
|
||||||
|
-XX:+UseStringDeduplication
|
||||||
|
-XX:+UseAES
|
||||||
|
-XX:+UseAESIntrinsics
|
||||||
|
-XX:+UseFMA
|
||||||
|
-XX:+UseLoopPredicate
|
||||||
|
-XX:+RangeCheckElimination
|
||||||
|
-XX:+OptimizeStringConcat
|
||||||
|
-XX:+UseCompressedOops
|
||||||
|
-XX:+UseThreadPriorities
|
||||||
|
-XX:+OmitStackTraceInFastThrow
|
||||||
|
-XX:+RewriteBytecodes
|
||||||
|
-XX:+RewriteFrequentPairs
|
||||||
|
-XX:+UseFPUForSpilling
|
||||||
|
-XX:+UseVectorCmov
|
||||||
|
-XX:+UseXMMForArrayCopy
|
||||||
|
-XX:+EliminateLocks
|
||||||
|
-XX:+DoEscapeAnalysis
|
||||||
|
-XX:+AlignVector
|
||||||
|
-XX:+OptimizeFill
|
||||||
|
-XX:+EnableVectorSupport
|
||||||
|
-XX:+UseCharacterCompareIntrinsics
|
||||||
|
-XX:+UseCopySignIntrinsic
|
||||||
|
-XX:+UseVectorStubs
|
||||||
|
"
|
||||||
|
if [[ $(arch) == "x86_64" ]]; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UseFastStosb
|
||||||
|
-XX:+UseNewLongLShift
|
||||||
|
-XX:+UseXmmI2D
|
||||||
|
-XX:+UseXmmI2F
|
||||||
|
-XX:+UseXmmLoadAndClearUpper
|
||||||
|
-XX:+UseXmmRegToRegMoveAll
|
||||||
|
-XX:UseAVX=2
|
||||||
|
-XX:UseSSE=4
|
||||||
|
"
|
||||||
|
else
|
||||||
|
log "cpu not x86_64, disabling architecture specific flags"
|
||||||
|
fi
|
||||||
|
if [[ $java_major_version -gt 23 ]]; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UseCompactObjectHeaders
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then
|
||||||
|
if [[ $java_major_version -gt 23 ]]; then
|
||||||
|
log "Java 24 or higher detected, using modified GraalVM flags"
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UseFastJNIAccessors
|
||||||
|
-XX:+UseInlineCaches
|
||||||
|
-XX:+SegmentedCodeCache
|
||||||
|
-Djdk.nio.maxCachedBufferSize=262144
|
||||||
|
-Djdk.graal.UsePriorityInlining=true
|
||||||
|
-Djdk.graal.Vectorization=true
|
||||||
|
-Djdk.graal.OptDuplication=true
|
||||||
|
-Djdk.graal.DetectInvertedLoopsAsCounted=true
|
||||||
|
-Djdk.graal.LoopInversion=true
|
||||||
|
-Djdk.graal.VectorizeHashes=true
|
||||||
|
-Djdk.graal.EnterprisePartialUnroll=true
|
||||||
|
-Djdk.graal.VectorizeSIMD=true
|
||||||
|
-Djdk.graal.StripMineNonCountedLoops=true
|
||||||
|
-Djdk.graal.SpeculativeGuardMovement=true
|
||||||
|
-Djdk.graal.TuneInlinerExploration=1
|
||||||
|
-Djdk.graal.LoopRotation=true
|
||||||
|
-Djdk.graal.CompilerConfiguration=enterprise
|
||||||
|
"
|
||||||
|
else
|
||||||
|
log "Using MeowIce's flags for Graalvm"
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UseFastJNIAccessors
|
||||||
|
-XX:+UseInlineCaches
|
||||||
|
-XX:+SegmentedCodeCache
|
||||||
|
-Djdk.nio.maxCachedBufferSize=262144
|
||||||
|
-Dgraal.UsePriorityInlining=true
|
||||||
|
-Dgraal.Vectorization=true
|
||||||
|
-Dgraal.OptDuplication=true
|
||||||
|
-Dgraal.DetectInvertedLoopsAsCounted=true
|
||||||
|
-Dgraal.LoopInversion=true
|
||||||
|
-Dgraal.VectorizeHashes=true
|
||||||
|
-Dgraal.EnterprisePartialUnroll=true
|
||||||
|
-Dgraal.VectorizeSIMD=true
|
||||||
|
-Dgraal.StripMineNonCountedLoops=true
|
||||||
|
-Dgraal.SpeculativeGuardMovement=true
|
||||||
|
-Dgraal.TuneInlinerExploration=1
|
||||||
|
-Dgraal.LoopRotation=true
|
||||||
|
-Dgraal.OptWriteMotion=true
|
||||||
|
-Dgraal.CompilerConfiguration=enterprise
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_FLARE_FLAGS}"; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
-XX:+UnlockDiagnosticVMOptions
|
||||||
|
-XX:+DebugNonSafepoints
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isTrue "${USE_SIMD_FLAGS}"; then
|
||||||
|
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||||
|
--add-modules=jdk.incubator.vector
|
||||||
|
"
|
||||||
|
fi
|
||||||
Executable
+130
@@ -0,0 +1,130 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
useGeneratedLogs=${GENERATE_LOG4J2_CONFIG:-${ENABLE_ROLLING_LOGS:-false}}
|
||||||
|
useFallbackJvmFlag=false
|
||||||
|
|
||||||
|
patchLog4jConfig() {
|
||||||
|
file=${1?}
|
||||||
|
url=${2?}
|
||||||
|
if ! get -o "${SERVER_DIR}/${file}" "$url"; then
|
||||||
|
logError "Failed to download corrected log4j config, fallback to JVM flag"
|
||||||
|
useFallbackJvmFlag=true
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
JVM_OPTS="-Dlog4j.configurationFile=${file} ${JVM_OPTS}"
|
||||||
|
useGeneratedLogs=false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temporarily disable debugging output
|
||||||
|
oldState=$(shopt -po xtrace || true)
|
||||||
|
shopt -u -o xtrace
|
||||||
|
# Patch Log4j remote code execution vulnerability
|
||||||
|
# See https://www.minecraft.net/en-us/article/important-message--security-vulnerability-java-edition
|
||||||
|
if isFamily NATIVE; then
|
||||||
|
: # Native server, so there is no log4j to patch
|
||||||
|
elif versionLessThan 1.7; then
|
||||||
|
: # No patch required here.
|
||||||
|
elif isFamily VANILLA && versionLessThan 1.12; then
|
||||||
|
patchLog4jConfig log4j2_17-111.xml https://launcher.mojang.com/v1/objects/dd2b723346a8dcd48e7f4d245f6bf09e98db9696/log4j2_17-111.xml
|
||||||
|
elif isFamily VANILLA && versionLessThan 1.17; then
|
||||||
|
patchLog4jConfig log4j2_112-116.xml https://launcher.mojang.com/v1/objects/02937d122c86ce73319ef9975b58896fc1b491d1/log4j2_112-116.xml
|
||||||
|
# See https://purpurmc.org/docs/Log4j/
|
||||||
|
elif isType PURPUR && versionLessThan 1.17; then
|
||||||
|
patchLog4jConfig purpur_log4j2_1141-1165.xml https://purpurmc.org/docs/xml/purpur_log4j2_1141-1165.xml
|
||||||
|
elif isType PURPUR && versionLessThan 1.18.1; then
|
||||||
|
patchLog4jConfig purpur_log4j2_117.xml https://purpurmc.org/docs/xml/purpur_log4j2_117.xml
|
||||||
|
elif versionLessThan 1.18.1; then
|
||||||
|
useFallbackJvmFlag=true
|
||||||
|
fi
|
||||||
|
eval "$oldState"
|
||||||
|
|
||||||
|
if ${useFallbackJvmFlag}; then
|
||||||
|
JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true ${JVM_OPTS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if isFamily NATIVE; then
|
||||||
|
: # Native server, so no Log4jPatcher agent
|
||||||
|
elif versionLessThan 1.7; then
|
||||||
|
: # No patch required here.
|
||||||
|
elif versionLessThan 1.18.1; then
|
||||||
|
if isTrue "${SKIP_LOG4J_PATCHER:-false}"; then
|
||||||
|
log "Skipping Log4jPatcher, make sure you are not affected"
|
||||||
|
else
|
||||||
|
JVM_OPTS="-javaagent:/image/Log4jPatcher.jar ${JVM_OPTS}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set up log4j2 configuration with templating support
|
||||||
|
LOGFILE="${SERVER_DIR}/log4j2.xml"
|
||||||
|
if isFamily NATIVE; then
|
||||||
|
: # Native server, so no log4j configuration
|
||||||
|
elif ${useGeneratedLogs}; then
|
||||||
|
# Set up log configuration defaults
|
||||||
|
: "${LOG_LEVEL:=info}"
|
||||||
|
: "${ROLLING_LOG_MAX_FILES:=1000}"
|
||||||
|
# Note: Can't use ${VAR:=default} syntax for values containing } as it breaks parsing
|
||||||
|
if [ -z "${ROLLING_LOG_FILE_PATTERN}" ]; then
|
||||||
|
ROLLING_LOG_FILE_PATTERN='logs/%d{yyyy-MM-dd}-%i.log.gz'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pattern format defaults (compatible with vanilla Minecraft)
|
||||||
|
# Note: Can't use ${VAR:=default} syntax because } in the value breaks parsing
|
||||||
|
if [ -z "${LOG_CONSOLE_FORMAT}" ]; then
|
||||||
|
LOG_CONSOLE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
||||||
|
fi
|
||||||
|
if [ -z "${LOG_TERMINAL_FORMAT}" ]; then
|
||||||
|
LOG_TERMINAL_FORMAT='[%d{HH:mm:ss} %level]: %msg%n'
|
||||||
|
fi
|
||||||
|
if [ -z "${LOG_FILE_FORMAT}" ]; then
|
||||||
|
LOG_FILE_FORMAT='[%d{HH:mm:ss}] [%t/%level]: %msg%n'
|
||||||
|
fi
|
||||||
|
|
||||||
|
export LOG_LEVEL ROLLING_LOG_FILE_PATTERN ROLLING_LOG_MAX_FILES
|
||||||
|
export LOG_CONSOLE_FORMAT LOG_TERMINAL_FORMAT LOG_FILE_FORMAT
|
||||||
|
|
||||||
|
|
||||||
|
# Always regenerate if file doesn't exist
|
||||||
|
if [ ! -e "$LOGFILE" ] || isTrue "${REGENERATE_LOG4J2:-true}"; then
|
||||||
|
log "Generating log4j2.xml from template in ${LOGFILE}"
|
||||||
|
|
||||||
|
# Generate log4j2.xml using heredoc for reliable variable substitution
|
||||||
|
cat > "$LOGFILE" <<EOF
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="WARN">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="SysOut" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="${LOG_CONSOLE_FORMAT}" />
|
||||||
|
</Console>
|
||||||
|
<Queue name="TerminalConsole">
|
||||||
|
<PatternLayout pattern="${LOG_TERMINAL_FORMAT}" />
|
||||||
|
</Queue>
|
||||||
|
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="${ROLLING_LOG_FILE_PATTERN}">
|
||||||
|
<PatternLayout pattern="${LOG_FILE_FORMAT}" />
|
||||||
|
<Policies>
|
||||||
|
<TimeBasedTriggeringPolicy />
|
||||||
|
<OnStartupTriggeringPolicy />
|
||||||
|
</Policies>
|
||||||
|
<DefaultRolloverStrategy max="${ROLLING_LOG_MAX_FILES}"/>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="${LOG_LEVEL}">
|
||||||
|
<filters>
|
||||||
|
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||||
|
</filters>
|
||||||
|
<AppenderRef ref="SysOut"/>
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
|
<AppenderRef ref="TerminalConsole"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
log "log4j2.xml already exists and is up to date, skipping generation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply the log4j2 configuration
|
||||||
|
JVM_OPTS="-Dlog4j.configurationFile=log4j2.xml ${JVM_OPTS}"
|
||||||
|
else
|
||||||
|
rm -f "${LOGFILE}"
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user