#!/usr/bin/env bash

echo "Generating logrotate configuration from template"

# logrotate config depends on log path
envsubst '\$AVIA_SF_YT_LOG_PATH \$AVIA_SF_LOG_PATH' \
< /tmp/templates/status-importer.logrotate.template \
> /etc/logrotate.d/status-importer.logrotate

chmod 644 -R "${AVIA_SF_YT_LOG_PATH}"
chmod 644 -R "${AVIA_SF_LOG_PATH}"
chmod 644 /etc/logrotate.d/status-importer.logrotate
