mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-04-22 21:39:26 +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:
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 $@
|
||||
Reference in New Issue
Block a user