You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/bin/bash
. lib/common
set -e
root_crontab="$SERVICE_CONFIGSTORE/etc/crontabs/root"
cron_content=$(set pipefail; cron:entries | tr '\0' '\n') || { err "Failed to make cron entries" >&2 exit 1 } if [ -z "${cron_content::1}" ]; then err "Unexpected empty scheduled command list." exit 1 fi if [ -e "$root_crontab" ]; then if ! [ -f "$root_crontab" ]; then err "Destination '$root_crontab' exists and is not a file." exit 1 fi current_content=$(cat "$root_crontab") if [ "$current_content" = "$cron_content" ]; then info "Cron entry already up to date." exit 0 fi fi
if ! [ -d "${root_crontab%/*}" ]; then mkdir -p "${root_crontab%/*}" fi
printf "%s\n" "$cron_content" > "$root_crontab" ## Busybox cron uses cron.update file to rescan new cron entries ## cf: https://git.busybox.net/busybox/tree/miscutils/crond.c#n1089 touch "${root_crontab%/*}/cron.update"
info "Cron entry updated ${GREEN}successfully${NORMAL}."
|