From 1056d6cf90f8763165ed33ed99aa3bfd6f2ac9da Mon Sep 17 00:00:00 2001 From: Jonathan Sundqvist Date: Mon, 6 May 2019 09:55:19 +0200 Subject: [PATCH] Move crontab to recommended location --- README.md | 2 ++ install | 7 +++++++ post-extract | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 install diff --git a/README.md b/README.md index 84793a5..3a8c42e 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/install b/install new file mode 100644 index 0000000..9472ae0 --- /dev/null +++ b/install @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +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 "/etc/sudoers.d/dokku-supply-config" diff --git a/post-extract b/post-extract index db0adab..719ad0f 100755 --- a/post-extract +++ b/post-extract @@ -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 }