aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docker/schedule.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-02-25 19:34:23 +0100
committerEgor Tensin <Egor.Tensin@gmail.com>2023-02-25 19:34:23 +0100
commit8e0128a00dd0d94d167b93a6113f33a570b4ff28 (patch)
tree1a96d3023999f3a492c965fc8c3735df45175631 /docker/schedule.sh
parentfix a shebang for consistency (diff)
downloadcgitize-8e0128a00dd0d94d167b93a6113f33a570b4ff28.tar.gz
cgitize-8e0128a00dd0d94d167b93a6113f33a570b4ff28.zip
docker: rename schedule.sh to run_cron.sh
Diffstat (limited to 'docker/schedule.sh')
-rwxr-xr-xdocker/schedule.sh62
1 files changed, 0 insertions, 62 deletions
diff --git a/docker/schedule.sh b/docker/schedule.sh
deleted file mode 100755
index db7ae26..0000000
--- a/docker/schedule.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/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
-shopt -s inherit_errexit lastpipe
-
-schedule_to_cron() {
- local schedule
- for schedule; do
- case "$schedule" in
- 15min) echo '*/15 * * * *' ;;
- hourly) echo '0 * * * *' ;;
- daily) echo '0 0 * * *' ;;
- weekly) echo '0 0 * * 1' ;;
- monthly) echo '0 0 1 * *' ;;
- *)
- echo "$schedule"
- ;;
- esac
- done
-}
-
-make_task_script() {
- echo "#!/bin/bash
-cd -- "$( pwd )" && $( printf -- ' %q' "$@" )"
-}
-
-setup_cron_task() {
- local schedule
- schedule="${SCHEDULE:-once}"
-
- if [ "$schedule" = once ]; then
- exec "$@"
- fi
-
- schedule="$( schedule_to_cron "$schedule" )"
-
- make_task_script "$@" > /task.sh
- chmod +x /task.sh
-
- if [ -n "$SCHEDULE_ON_START" ]; then
- # Run the task once when the container is started.
- /task.sh
- fi
-
- local crontab
- crontab="$schedule /task.sh
-# This is the new crontab."
-
- echo "$crontab" | crontab -
- exec crond -f
-}
-
-main() {
- setup_cron_task "$@"
-}
-
-main "$@"