aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docker
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-03-30 02:21:21 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-03-30 09:40:13 +0300
commit1592e333be61ed600379d9a59ed68329d269f5f5 (patch)
treef4c2104e99963045eea83120a67a12352f19489a /docker
parentexamples: mention access tokens (diff)
downloadcgitize-1592e333be61ed600379d9a59ed68329d269f5f5.tar.gz
cgitize-1592e333be61ed600379d9a59ed68329d269f5f5.zip
docker: enable scheduled runs via crond
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/entrypoint.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100755
index 0000000..cf6eb77
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2021 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cgitize" project.
+# For details, see https://github.com/egor-tensin/cgitize.
+# Distributed under the MIT License.
+
+set -o errexit -o nounset -o pipefail
+
+schedule="${SCHEDULE:-once}"
+
+case "$schedule" in
+ once) exec "$@" ;;
+ 15min) schedule='*/15 * * * *' ;;
+ hourly) schedule='0 * * * *' ;;
+ daily) schedule='0 0 * * *' ;;
+ weekly) schedule='0 0 * * 1' ;;
+ monthly) schedule='0 0 1 * *' ;;
+ *) ;;
+esac
+
+script="#!/bin/bash
+cd /usr/src &&$( printf -- ' %q' "$@" )"
+
+echo "$script" > /task.sh
+chmod +x /task.sh
+
+crontab="$schedule /task.sh
+# This is the new crontab."
+
+echo "$crontab" | crontab -
+
+crond -f