Skip to content

Commit fb7052e

Browse files
authored
Merge pull request #9 from linuxserver/bullseye-cron
standard cron
2 parents 3ead8c3 + 49c963d commit fb7052e

File tree

9 files changed

+51
-0
lines changed

9 files changed

+51
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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 \

Dockerfile.aarch64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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 \
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-crontab-config/run

root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies.d/init-services

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
longrun

root/etc/s6-overlay/s6-rc.d/user/svc-cron

Whitespace-only changes.

0 commit comments

Comments
 (0)