#!/usr/bin/env bash

echo "Generating push-client config from template"
# push-client depends on log path
envsubst '\$AVIA_SF_YT_LOG_PATH' \
< /tmp/templates/files.yaml.template \
> /etc/yandex/statbox-push-client/files.yaml

echo "Making directories for push-client logs"
# AVIAINFRA-23 - Directory for YT-logs must be created beforehand
# so we dynamically took paths from push-client config and make sure of their existence.
cat /etc/yandex/statbox-push-client/files.yaml |
grep -oE 'name: .+' |
cut -d':' -f2- |
xargs -L1 dirname |
xargs mkdir -p
