mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
feat(minecraft-server): replace environment variables in configs
Add additional setup script that replaces environment variables inside config files. Closes #298
This commit is contained in:
parent
1cc902062a
commit
b51b19b3c0
@ -3,19 +3,19 @@ FROM openjdk:8u171-jre-alpine
|
||||
LABEL maintainer "itzg"
|
||||
|
||||
RUN apk add --no-cache -U \
|
||||
openssl \
|
||||
imagemagick \
|
||||
lsof \
|
||||
su-exec \
|
||||
shadow \
|
||||
bash \
|
||||
curl iputils wget \
|
||||
git \
|
||||
jq \
|
||||
mysql-client \
|
||||
tzdata \
|
||||
rsync \
|
||||
python python-dev py2-pip
|
||||
openssl \
|
||||
imagemagick \
|
||||
lsof \
|
||||
su-exec \
|
||||
shadow \
|
||||
bash \
|
||||
curl iputils wget \
|
||||
git \
|
||||
jq \
|
||||
mysql-client \
|
||||
tzdata \
|
||||
rsync \
|
||||
python python-dev py2-pip
|
||||
|
||||
RUN pip install mcstatus
|
||||
|
||||
@ -71,7 +71,8 @@ ENV UID=1000 GID=1000 \
|
||||
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
|
||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= LEVEL=world \
|
||||
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= MODS= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true SERVER_NAME="Dedicated Server"
|
||||
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= MODS= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true SERVER_NAME="Dedicated Server" \
|
||||
REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_"
|
||||
|
||||
COPY start* /
|
||||
RUN dos2unix /start* && chmod +x /start*
|
||||
|
@ -132,4 +132,4 @@ else
|
||||
echo "server.properties already created, skipping"
|
||||
fi
|
||||
|
||||
exec /start-minecraftFinalSetup $@
|
||||
exec /start-finalSetup05EnvVariables $@
|
||||
|
15
minecraft-server/start-finalSetup05EnvVariables
Normal file
15
minecraft-server/start-finalSetup05EnvVariables
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$REPLACE_ENV_VARIABLES" = "TRUE" ]; then
|
||||
echo "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||
while IFS='=' read -r name value ; do
|
||||
# check if name of env variable matches the prefix
|
||||
# sanity check environment variables to avoid code injections
|
||||
if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] && [[ $value =~ ^[0-9a-zA-Z_\-:/=?.+]*$ ]] && [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then
|
||||
echo "$name = $value"
|
||||
find /data/ -type f -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||
fi
|
||||
done < <(env)
|
||||
fi
|
||||
|
||||
exec /start-minecraftFinalSetup $@
|
Loading…
Reference in New Issue
Block a user