Process placeholders in server properties values (#2484)

This commit is contained in:
Geoff Bourne 2023-11-12 13:21:16 -06:00 committed by GitHub
parent eb279d0fa0
commit 37a5d50f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -42,7 +42,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=1.9.1 --var app=mc-server-runner --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.36.8
ARG MC_HELPER_VERSION=1.36.9
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
# used for cache busting local copy of mc-image-helper
ARG MC_HELPER_REV=1

View File

@ -4,6 +4,37 @@ If you prefer to manually manage the `server.properties` file, set `OVERRIDE_SER
> NOTE: to clear a server property, set the variable to an empty string, such as `-e RESOURCE_PACK=""`. A variables that maps to a server property that is unset, is ignored and the existing `server.property` is left unchanged.
## Placeholders
Any of the server properties mapped from the environment variables [below](#properties), may contain placeholders that are replaced when the `server.properties` file is updated. The syntax of placeholders is DOS-style, `%VAR%` to avoid being processed by Docker or the shell.
The following options are available for placeholders:
`%VAR%`
: Replaced with the value of the environment variable `VAR`
`%env:VAR%`
: Also, replaced with the value of the environment variable `VAR`
`%date:FMT%`
: The `FMT` string is processed by [Java's DateTimeFormatter](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatter.html) and the current date/time is formatted.
Any declared or resolved environment variable may be referenced, such as `VERSION` and `TYPE`. Additionally, [Modrinth](../types-and-platforms/mod-platforms/modrinth-modpacks.md) and [Auto CurseForge](../types-and-platforms/mod-platforms/auto-curseforge.md) modpacks will expose the environment variables `MODPACK_NAME` and `MODPACK_VERSION`.
!!! example
As a compose file environment entry:
```yaml
MOTD: Running %MODPACK_NAME% version %env:MODPACK_VERSION%
LEVEL: world-%date:yyyy-MM-dd%
```
## Properties
### Message of the Day
The message of the day, shown below each server entry in the client UI, can be changed with the `MOTD` environment variable, such as