mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-07-17 05:54:55 +00:00
Fixed "REPLACE_ENV_VARIABLES_EXCLUDE_PATHS" breaking cfg replacer when set. (#598)
This commit is contained in:
@@ -329,7 +329,7 @@ Specific files can be excluded by listing their name (without path) in the varia
|
|||||||
Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path
|
Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path
|
||||||
excludes are recursive. Here is an example:
|
excludes are recursive. Here is an example:
|
||||||
```
|
```
|
||||||
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata/ /data/plugins/MyPlugin/"
|
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata /data/plugins/MyPlugin"
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is a full example where we want to replace values inside a `database.yml`.
|
Here is a full example where we want to replace values inside a `database.yml`.
|
||||||
|
|||||||
@@ -6,20 +6,21 @@
|
|||||||
|
|
||||||
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
||||||
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||||
findExcludes=
|
|
||||||
|
|
||||||
# File excludes
|
# File excludes
|
||||||
|
fileExcludes=
|
||||||
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
||||||
findExcludes="${findExcludes} -not -name $f"
|
fileExcludes="${fileExcludes} -not -name $f"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Directory excludes (recursive)
|
# Directory excludes (recursive)
|
||||||
dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS})
|
dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS})
|
||||||
if [[ $dirExcludes ]]; then
|
if [[ $dirExcludes ]]; then
|
||||||
findExcludes+=" -type d ( -path ${dirExcludes} ) -prune"
|
dirExcludes=" -type d ( -path ${dirExcludes} ) -prune -o"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
isDebugging && echo "Using find exclusions: $findExcludes"
|
isDebugging && echo "Using find file exclusions: $fileExcludes"
|
||||||
|
isDebugging && echo "Using find directory exclusions: $dirExcludes"
|
||||||
|
|
||||||
while IFS='=' read -r name value ; do
|
while IFS='=' read -r name value ; do
|
||||||
# check if name of env variable matches the prefix
|
# check if name of env variable matches the prefix
|
||||||
@@ -34,10 +35,12 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
log "Replacing $name with $value ..."
|
log "Replacing $name with $value ..."
|
||||||
find /data/ -type f \
|
find /data/ \
|
||||||
|
$dirExcludes \
|
||||||
|
-type f \
|
||||||
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
|
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
|
||||||
-or -name "*.conf" -or -name "*.properties" \) \
|
-or -name "*.conf" -or -name "*.properties" \) \
|
||||||
$findExcludes \
|
$fileExcludes \
|
||||||
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||||
fi
|
fi
|
||||||
done < <(env)
|
done < <(env)
|
||||||
|
|||||||
Reference in New Issue
Block a user