fix yq behavior with bind-mount config.yaml (#1968)

Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
This commit is contained in:
mmetc 2023-01-09 21:47:25 +01:00 committed by GitHub
parent 943bb58086
commit d986ae0ee5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,9 +69,10 @@ conf_set() {
else
YAML_FILE="$CONFIG_FILE"
fi
YAML_CONTENT=$(cat "$YAML_FILE" 2>/dev/null || true)
NEW_CONTENT=$(echo "$YAML_CONTENT" | yq e "$1")
echo "$NEW_CONTENT" | install -m 0600 /dev/stdin "$YAML_FILE"
if [ ! -f "$YAML_FILE" ]; then
install -m 0600 /dev/null "$YAML_FILE"
fi
yq e "$1" -i "$YAML_FILE"
}
# conf_set_if(): used to update the configuration