diff --git a/opensciencegrid/logrotate/Dockerfile b/opensciencegrid/logrotate/Dockerfile index fedfc700..5e368c89 100644 --- a/opensciencegrid/logrotate/Dockerfile +++ b/opensciencegrid/logrotate/Dockerfile @@ -14,4 +14,5 @@ RUN yum install -y crontabs \ logrotate \ && yum clean all -CMD [ "sh", "-c", "echo \"$CRON_EXPR /usr/sbin/logrotate $LOGROTATE_OPTIONS $LOGROTATE_CONF\" '> /proc/$(cat /var/run/crond.pid)/fd/1 2>&1' | crontab - && crond -n"] +COPY startup.sh /bin/ +CMD [ "/bin/startup.sh" ] diff --git a/opensciencegrid/logrotate/startup.sh b/opensciencegrid/logrotate/startup.sh new file mode 100755 index 00000000..a7210170 --- /dev/null +++ b/opensciencegrid/logrotate/startup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Create a cron file on the fly based on docker environment variables, +# Then immediately pipe it to crontab +echo "$CRON_EXPR /usr/sbin/logrotate $LOGROTATE_OPTIONS $LOGROTATE_CONF" '> /proc/$(cat /var/run/crond.pid)/fd/1 2>&1' | crontab - + +# Start cron in non-daemon (foreground) mode +crond -n