Skip to content

Commit da72f8f

Browse files
Merge pull request #228 from mwestphall/bugfix/cleanup-logrotate-entrypoint
Create a startup.sh script to make the quote-mangling for the crontab generation a bit more clear
2 parents 954c392 + fd32889 commit da72f8f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

opensciencegrid/logrotate/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ RUN yum install -y crontabs \
1414
logrotate \
1515
&& yum clean all
1616

17-
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"]
17+
COPY startup.sh /bin/
18+
CMD [ "/bin/startup.sh" ]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Create a cron file on the fly based on docker environment variables,
4+
# Then immediately pipe it to crontab
5+
echo "$CRON_EXPR /usr/sbin/logrotate $LOGROTATE_OPTIONS $LOGROTATE_CONF" '> /proc/$(cat /var/run/crond.pid)/fd/1 2>&1' | crontab -
6+
7+
# Start cron in non-daemon (foreground) mode
8+
exec crond -n
9+
echo >&2 "Exec failed!"
10+
exit 255

0 commit comments

Comments
 (0)