You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've make some changes to the docker-redmine container and commited changes to the new image to save my work under new tag. After starting this altered image I've noticed, that REDMINE_FETCH_COMMITS was duplicated in the crontab. And after second commit I actually got three same commands in the crontab...
I think it's reasonable to grep current crontab for the presence of the line which is going to be (re)added. Here is the way I've implemented it:
--- a/assets/init
+++ b/assets/init
@@ -428,14 +428,18 @@ if [ -d ${DATA_DIR}/themes ]; then
fi
# create a cronjob to periodically fetch commits
+REDMINE_CRONJOB_FILE=/tmp/cron.redmine
case "${REDMINE_FETCH_COMMITS}" in
hourly|daily|monthly)
set +e
- crontab -u redmine -l 2>/dev/null >/tmp/cron.redmine
+ crontab -u redmine -l 2>/dev/null >${REDMINE_CRONJOB_FILE}
set -e
- echo "@${REDMINE_FETCH_COMMITS} cd /home/redmine/redmine && ./script/rails runner \"Repository.fetch_changesets\" -e production >> log/cron_rake.log 2>&1" >>/tmp/cron.redmine
- crontab -u redmine /tmp/cron.redmine 2>/dev/null
- rm -rf /tmp/cron.redmine
+ REDMINE_FETCH_CRONJOB="@${REDMINE_FETCH_COMMITS} cd /home/redmine/redmine && ./script/rails runner \"Repository.fetch_changesets\" -e production >> log/cron_rake.log 2>&1"
+ if ! fgrep "${REDMINE_FETCH_CRONJOB}" ${REDMINE_CRONJOB_FILE} >/dev/null; then
+ echo "${REDMINE_FETCH_CRONJOB}" >>${REDMINE_CRONJOB_FILE}
+ crontab -u redmine ${REDMINE_CRONJOB_FILE} 2>/dev/null
+ fi
+ rm -f ${REDMINE_CRONJOB_FILE}
;;
esac
That should fix the problem.
The text was updated successfully, but these errors were encountered:
I've make some changes to the docker-redmine container and commited changes to the new image to save my work under new tag. After starting this altered image I've noticed, that REDMINE_FETCH_COMMITS was duplicated in the crontab. And after second commit I actually got three same commands in the crontab...
I think it's reasonable to grep current crontab for the presence of the line which is going to be (re)added. Here is the way I've implemented it:
That should fix the problem.
The text was updated successfully, but these errors were encountered: