#!/usr/bin/env bash
set -Eeo pipefail

echo "Creating CRON entry for rake redmine:send_reminders"
echo "$REDMINE_SEND_REMINDERS_CRON_EXPR redmine GEM_HOME=/usr/local/bundle BUNDLE_APP_CONFIG=/usr/local/bundle /usr/local/bin/rake -f /usr/src/redmine/Rakefile redmine:send_reminders days=$REDMINE_SEND_REMINDERS_DAYS RAILS_ENV=production" > /etc/cron.d/redmine
chmod 0644 /etc/cron.d/redmine
crontab /etc/cron.d/redmine

service cron start

set -- /orig-entrypoint.sh "$@"
echo Executing original Redmine "$@"
exec "$@"