feat: schedule with busybox crond instead of supercronic

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
This commit is contained in:
trex Bot committed 2026-11-24 22:24:29 -06:00
1 parent 313db934e4
commit ce825c7526
3 files changed
+40 -8

No files matched your search

+20 -5
View File
@@ -3,10 +3,25 @@ set -eu
: "${CRON:=0 3 * * *}"
# /opt is read-only when the container runs with read_only: true, so the
# generated crontab lives on the tmpfs.
CRON_CONFIG_FILE=/tmp/crontab
# 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
printf '%s /usr/local/bin/seafile-backup\n' "$CRON" > "$CRON_CONFIG_FILE"
# The rootfs is read-only, so the generated crontab lives on the tmpfs.
CRON_DIR=/tmp/crontabs
mkdir -p "$CRON_DIR"
exec supercronic -passthrough-logs -quiet "$CRON_CONFIG_FILE"
# 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"