24 lines
601 B
Bash
Executable File
24 lines
601 B
Bash
Executable File
#!/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
|
|
|
|
echo "install-cron: ${CRON_FILE} installed (mode 0644)"
|