Skip to content

Commit d388077

Browse files
committed
cron in base
Signed-off-by: Eric Nemchik <[email protected]>
1 parent e196590 commit d388077

File tree

8 files changed

+44
-0
lines changed

8 files changed

+44
-0
lines changed

root/etc/s6-overlay/s6-rc.d/init-crontab-config/dependencies.d/init-os-end

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
for cron_user in abc root; do
5+
if [[ -f "/defaults/crontabs/${cron_user}" ]]; then
6+
# make folders
7+
mkdir -p \
8+
/config/crontabs
9+
10+
# if crontabs do not exist in config
11+
if [[ ! -f "/config/crontabs/${cron_user}" ]]; then
12+
# copy crontab from system
13+
if crontab -l -u "${cron_user}" >/dev/null; then
14+
crontab -l -u "${cron_user}" >"/config/crontabs/${cron_user}"
15+
fi
16+
17+
# if crontabs still do not exist in config (were not copied from system)
18+
# copy crontab from image defaults (using -n, do not overwrite an existing file)
19+
cp -n "/defaults/crontabs/${cron_user}" /config/crontabs/
20+
fi
21+
22+
# set permissions and import user crontabs
23+
lsiown "${cron_user}":"${cron_user}" "/config/crontabs/${cron_user}"
24+
crontab -u "${cron_user}" "/config/crontabs/${cron_user}"
25+
fi
26+
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 && [[ -n "$(crontab -l -u abc)" || -n "$(crontab -l -u root)" ]]; then
5+
if builtin command -v busybox >/dev/null && [[ $(busybox) =~ [[: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)