#!/bin/bash

REDMINE_LOCAL_PATH="/var/local/redmine"

if [ ! -z "$GIT_SYNC_FOLDER" ]; then
	mkdir -p "$GIT_SYNC_FOLDER"
	chown redmine:redmine "$GIT_SYNC_FOLDER"
fi

cat <<EOT >> "$REDMINE_LOCAL_PATH/update-repositories.env"
REDMINE_API_KEY=${REDMINE_API_KEY}
GIT_SYNC_FOLDER=${GIT_SYNC_FOLDER}
EOT

/usr/sbin/cron
crontab -u root /var/local/redmine/crontab

/docker-entrypoint.sh rails server -b 0.0.0.0
