Last active
August 29, 2015 14:15
-
-
Save mlebkowski/bda94232a266dbdf45d7 to your computer and use it in GitHub Desktop.
dokku post-release hook for crontab jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x | |
APP="$1"; IMAGE="dokku/$APP" | |
CRONTABS_DIR=$DOKKU_ROOT/.crontab | |
CONFIG_FILE=$CRONTABS_DIR/$APP.conf | |
mkdir -p "$CRONTABS_DIR"; | |
docker run -i -a stdout "$IMAGE" cat /app/crontab \ | |
| sed s_'%CONTAINER'_"docker run -e CRON=1 -i -a stdout $IMAGE /exec"_g > "$CONFIG_FILE" | |
[ ! -s "$CONFIG_FILE" ] && echo " Installing crontab" || rm "$CONFIG_FILE" || : | |
cat "$CRONTABS_DIR"/* > "$CRONTABS_DIR/crontab" | |
crontab "$CRONTABS_DIR/crontab" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment