Skip to content

Commit

Permalink
Move crontab to recommended location
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-s committed May 10, 2019
1 parent b993dcf commit 86ce198
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ This plugin provides hooks:
This plugin allows you to store configuration files which reside in the dokku app directory, such as ENV, inside the app's git repository.

For example, say you want to include a file called DOCKER_OPTIONS for the [Docker options plugin](https://github.com/dyson/dokku-docker-options). In the root directory of your app repository, create a directory called `.dokku` and put the files in there. This plugin will copy those files into `$DOKKU_ROOT/$APP/` before building the app.

Optionally if you place a `crontab` in `.dokku` it will move this crontab file to `/etc/cron.d/$APP`
7 changes: 7 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x


echo "%dokku ALL=(ALL) NOPASSWD: /bin/cp, /usr/sbin/service cron restart" > /etc/sudoers.d/dokku-supply-config
chmod 0440 "$_SUDOERS_FILE"
6 changes: 6 additions & 0 deletions post-extract
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ suppy-config-post-extract() {
if [[ -d "$TMPDIR/.dokku" ]] && [[ "$(ls -A "$TMPDIR/.dokku")" ]]; then
output=$(cp -r "$TMPDIR/.dokku/." "$DOKKU_ROOT/$APP")
dokku_log_verbose_quiet "$output"

if [[ "$(ls -A "$TMPDIR/.dokku/crontab")" ]]; then
output=$(sudo cp -r "$TMPDIR/.dokku/crontab" "/etc/cron.d/$APP")
dokku_log_verbose_quiet "$output"
sudo service cron restart
fi
fi
}

Expand Down

0 comments on commit 86ce198

Please sign in to comment.