From 0d8eaa9dce347de34fdfe370af79db443427d4d9 Mon Sep 17 00:00:00 2001 From: xZero707 Date: Thu, 16 May 2024 18:34:35 +0200 Subject: [PATCH] Add own crond service --- Dockerfile | 3 --- rootfs/etc/s6-overlay/s6-rc.d/crond/run | 18 ++++++++++++++++++ rootfs/etc/s6-overlay/s6-rc.d/crond/type | 1 + rootfs/etc/s6-overlay/s6-rc.d/crond/up | 1 + .../s6-overlay/s6-rc.d/user/contents.d/crond | 0 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/crond/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/crond/type create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/crond/up create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/crond diff --git a/Dockerfile b/Dockerfile index 6374dc9..4c6c789 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,9 +19,6 @@ FROM scratch AS rootfs # Install attr utility COPY --from=nlss/attr ["/usr/local/bin/attr", "/usr/local/bin/"] -# Add crond service -COPY --from=ghcr.io/n0rthernl1ghts/base-alpine:3.17 ["/etc/services.d/cron/", "/etc/services.d/cron/"] - # WordPress specific php configuration COPY --from=wordpress ["/usr/local/etc/php/conf.d/opcache-recommended.ini", "/usr/local/etc/php/conf.d/error-logging.ini", "/usr/local/etc/php/conf.d/"] diff --git a/rootfs/etc/s6-overlay/s6-rc.d/crond/run b/rootfs/etc/s6-overlay/s6-rc.d/crond/run new file mode 100755 index 0000000..ede8d33 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/crond/run @@ -0,0 +1,18 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +# crond main +main() { + # This will prepend service name to all output from here + exec > >(while read line; do echo "[crond] ${line}"; done) 2>&1 + + if [[ "${CRON_ENABLED}" == "false" || "${CRON_ENABLED}" == "0" ]] + then + echo "CRON_ENABLED is set to false. Service disabled" + sleep infinity + fi + + echo "Starting cron daemon" + /usr/sbin/crond -f -l 2 +} +main diff --git a/rootfs/etc/s6-overlay/s6-rc.d/crond/type b/rootfs/etc/s6-overlay/s6-rc.d/crond/type new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/crond/type @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/crond/up b/rootfs/etc/s6-overlay/s6-rc.d/crond/up new file mode 100644 index 0000000..7d816ee --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/crond/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/crond/run \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/crond b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/crond new file mode 100644 index 0000000..e69de29