Skip to content

Commit

Permalink
Create a startup.sh script to make the quote-mangling for the crontab…
Browse files Browse the repository at this point in the history
… generation a bit more clear
  • Loading branch information
mwestphall committed Jan 17, 2025
1 parent 2c21235 commit 584dc82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opensciencegrid/logrotate/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
8 changes: 8 additions & 0 deletions opensciencegrid/logrotate/startup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 584dc82

Please sign in to comment.