fix(minecraft-server): filter env replacement file

Environment variable replacement now only affects matching file types.

Closes #299
This commit is contained in:
Michael Reichenbach
2019-03-29 12:11:42 +01:00
parent 73046d7499
commit a316bd8f95
29 changed files with 2 additions and 2 deletions

View File

@@ -6,8 +6,8 @@ if [ "$REPLACE_ENV_VARIABLES" = "TRUE" ]; then
# 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' {} \;
echo "Replacing $name with $value ..."
find /data/ -type f \( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" -or -name "*.properties" \) -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
fi
done < <(env)
fi