File tree Expand file tree Collapse file tree 9 files changed +51
-0
lines changed
root/etc/s6-overlay/s6-rc.d Expand file tree Collapse file tree 9 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ RUN \
106106 locales && \
107107 echo "**** install packages ****" && \
108108 apt-get install -y \
109+ cron \
109110 curl \
110111 gnupg \
111112 jq \
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ RUN \
106106 locales && \
107107 echo "**** install packages ****" && \
108108 apt-get install -y \
109+ cron \
109110 curl \
110111 gnupg \
111112 jq \
Original file line number Diff line number Diff line change 1+ #!/usr/bin/with-contenv bash
2+ # shellcheck shell=bash
3+
4+ for cron_user in abc root; do
5+ if [[ -f "/etc/crontabs/${cron_user}" ]]; then
6+ lsiown "${cron_user}":"${cron_user}" "/etc/crontabs/${cron_user}"
7+ crontab -u "${cron_user}" "/etc/crontabs/${cron_user}"
8+ fi
9+
10+ if [[ -f "/defaults/crontabs/${cron_user}" ]]; then
11+ # make folders
12+ mkdir -p \
13+ /config/crontabs
14+
15+ # if crontabs do not exist in config
16+ if [[ ! -f "/config/crontabs/${cron_user}" ]]; then
17+ # copy crontab from system
18+ if crontab -l -u "${cron_user}" >/dev/null 2>&1; then
19+ crontab -l -u "${cron_user}" >"/config/crontabs/${cron_user}"
20+ fi
21+
22+ # if crontabs still do not exist in config (were not copied from system)
23+ # copy crontab from image defaults (using -n, do not overwrite an existing file)
24+ cp -n "/defaults/crontabs/${cron_user}" /config/crontabs/
25+ fi
26+
27+ # set permissions and import user crontabs
28+ lsiown "${cron_user}":"${cron_user}" "/config/crontabs/${cron_user}"
29+ crontab -u "${cron_user}" "/config/crontabs/${cron_user}"
30+ fi
31+ done
Original file line number Diff line number Diff line change 1+ oneshot
Original file line number Diff line number Diff line change 1+ /etc/s6-overlay/s6-rc.d/init-crontab-config/run
Original file line number Diff line number Diff line change 1+ #!/usr/bin/with-contenv bash
2+ # shellcheck shell=bash
3+
4+ if builtin command -v crontab >/dev/null 2>&1 && [[ -n "$(crontab -l -u abc 2>/dev/null || true)" || -n "$(crontab -l -u root 2>/dev/null || true)" ]]; then
5+ if builtin command -v busybox >/dev/null 2>&1 && [[ $(busybox || true) =~ [[:space:]](crond)([,]|$) ]]; then
6+ exec busybox crond -f -S -l 5
7+ elif [[ -f /usr/bin/apt ]] && [[ -f /usr/sbin/cron ]]; then
8+ exec /usr/sbin/cron -f -L 5
9+ else
10+ echo "**** cron not found ****"
11+ sleep infinity
12+ fi
13+ else
14+ sleep infinity
15+ fi
Original file line number Diff line number Diff line change 1+ longrun
You can’t perform that action at this time.
0 commit comments