mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
parent
c4c3613874
commit
825833c859
@ -71,7 +71,6 @@ ENV UID=1000 GID=1000 \
|
||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
|
||||
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
|
||||
REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_" \
|
||||
ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 AUTOPAUSE_PERIOD=10
|
||||
|
||||
COPY start* /
|
||||
|
@ -306,7 +306,7 @@ defined environment variables. Variables that you want to replace need to be wra
|
||||
inside `${YOUR_VARIABLE}` curly brackets and prefixed with a dollar sign. This is the regular
|
||||
syntax for enviromment variables inside strings or config files.
|
||||
|
||||
Optionally you can also define a prefix to only match predefined enviroment variables.
|
||||
Optionally you can also define a prefix to only match predefined environment variables.
|
||||
|
||||
`ENV_VARIABLE_PREFIX="CFG_"` <-- this is the default prefix
|
||||
|
||||
@ -322,6 +322,8 @@ There are some limitations to what characters you can use.
|
||||
Variables will be replaced in files with the following extensions:
|
||||
`.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`.
|
||||
|
||||
Specific files can be excluded by listing their name (without path) in the variable `REPLACE_ENV_VARIABLES_EXCLUDES`.
|
||||
|
||||
Here is a full example where we want to replace values inside a `database.yml`.
|
||||
|
||||
```yml
|
||||
|
@ -2,8 +2,17 @@
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
|
||||
: ${ENV_VARIABLE_PREFIX:=CFG_}
|
||||
|
||||
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
||||
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||
|
||||
findExcludes=
|
||||
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
||||
findExcludes="${findExcludes} -not -name $f"
|
||||
done
|
||||
isDebugging && echo "Using find exclusion: $findExcludes"
|
||||
|
||||
while IFS='=' read -r name value ; do
|
||||
# check if name of env variable matches the prefix
|
||||
# sanity check environment variables to avoid code injections
|
||||
@ -20,6 +29,7 @@ if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
|
||||
find /data/ -type f \
|
||||
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
|
||||
-or -name "*.conf" -or -name "*.properties" \) \
|
||||
$findExcludes \
|
||||
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||
fi
|
||||
done < <(env)
|
||||
|
Loading…
Reference in New Issue
Block a user