#!/bin/bash set -euo pipefail CRON_FILE="${1:-/etc/cron.d/tenbackward}" if [ ! -f "${CRON_FILE}" ]; then echo "install-cron: cron file ${CRON_FILE} does not exist" >&2 exit 1 fi if grep -q '__RUN_AT__' "${CRON_FILE}"; then echo "install-cron: refusing to install cron file with unresolved __RUN_AT__ placeholder" >&2 exit 1 fi chmod 0644 "${CRON_FILE}" if ! head -n 1 "${CRON_FILE}" | grep -qE '^[A-Z_]+='; then echo "install-cron: ${CRON_FILE} must start with a cron env line (e.g. SHELL=/bin/bash)" >&2 exit 1 fi if ! grep -q '/usr/local/bin/run-bot.sh' "${CRON_FILE}"; then echo "install-cron: ${CRON_FILE} must invoke /usr/local/bin/run-bot.sh" >&2 exit 1 fi if ! grep -qE '/proc/1/fd/1' "${CRON_FILE}"; then echo "install-cron: ${CRON_FILE} must redirect output to /proc/1/fd/1" >&2 exit 1 fi echo "install-cron: ${CRON_FILE} installed (mode 0644)"