kolla/docker/cron/extend_start.sh
Michal Arbet f229eb7e06 Make cron's logrotate schedule configurable
Kolla-ansible allows user to change logrotate.conf,
problem is that logrotate cron file is running
daily by default in all distros, this is sometimes
not enough. So, this patch is adding script and
way how to reconfigure schedule of logrotate job
(cron file).

Needed-By: https://review.opendev.org/c/openstack/kolla-ansible/+/813039

Change-Id: If31b08fcf45bafc0ab25498ece9208a576aae41b
2021-11-12 17:30:22 +01:00

18 lines
761 B
Bash

#!/bin/bash
CRON_LOGROTATE_CURRENT_PATH="$(find /etc/cron* -name logrotate)"
CRON_LOGROTATE_CURRENT_SCHEDULE=$(echo "${CRON_LOGROTATE_CURRENT_PATH}" | sed -r 's/(.*)(hourly|daily|weekly|monthly)(.*)/\2/g')
# Pass only for hourly|daily|weekly|monthly
if [[ "${KOLLA_LOGROTATE_SCHEDULE:-undefined}" =~ hourly|daily|weekly|monthly ]]; then
CRON_LOGROTATE_DESIRED_PATH="/etc/cron.${KOLLA_LOGROTATE_SCHEDULE}/logrotate"
if [[ "${CRON_LOGROTATE_CURRENT_PATH}" != "${CRON_LOGROTATE_DESIRED_PATH}" ]]; then
mv ${CRON_LOGROTATE_CURRENT_PATH} ${CRON_LOGROTATE_DESIRED_PATH}
CRON_LOGROTATE_CURRENT_SCHEDULE="${KOLLA_LOGROTATE_SCHEDULE}"
fi
fi
echo "[i] Cron schedule for logrotate is currently set to: ${CRON_LOGROTATE_CURRENT_SCHEDULE}."