Same scheduler qbit-maid uses: entrypoint.sh writes the crontab and execs crond -f. Drops the supercronic package from the image. - crontab lives in /tmp/crontabs because the rootfs is read-only - MAILTO= keeps job output on crond's stdout/stderr (container log), which is what supercronic -passthrough-logs provided - busybox crond only loads crontab files owned by uid 0 and calls initgroups() per job, so the container needs root + CAP_SETGID; the entrypoint now fails fast (exit 78) when it is not root - no @reboot job: a container restart must not start a backup
28 lines
876 B
Bash
28 lines
876 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
: "${CRON:=0 3 * * *}"
|
|
|
|
# busybox crond only loads crontab files owned by uid 0, and before every job
|
|
# it drops to the crontab's user with initgroups()/setgid()/setuid(). So this
|
|
# container has to run as root — the compose file sets user: '0:0' anyway,
|
|
# because Seafile writes some block files 0600 root:root.
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "entrypoint: crond needs root (crontab files must be owned by uid 0)" >&2
|
|
exit 78
|
|
fi
|
|
|
|
# The rootfs is read-only, so the generated crontab lives on the tmpfs.
|
|
CRON_DIR=/tmp/crontabs
|
|
mkdir -p "$CRON_DIR"
|
|
|
|
# MAILTO= (empty) keeps job output on crond's own stdout/stderr, i.e. the
|
|
# container log — the passthrough supercronic used to provide.
|
|
{
|
|
echo 'MAILTO='
|
|
printf '%s /usr/local/bin/seafile-backup\n' "$CRON"
|
|
} > "$CRON_DIR/root"
|
|
chmod 0600 "$CRON_DIR/root"
|
|
|
|
exec crond -f -c "$CRON_DIR"
|