Merge pull request #142 from linuxserver/standard-cron

standard cron
pull/146/head
Eric Nemchik 2023-11-02 10:56:12 -05:00 zatwierdzone przez GitHub
commit 62c88a2437
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
10 zmienionych plików z 46 dodań i 0 usunięć

Wyświetl plik

@ -110,6 +110,7 @@ RUN \
locales && \ locales && \
echo "**** install packages ****" && \ echo "**** install packages ****" && \
apt-get install -y \ apt-get install -y \
cron \
curl \ curl \
gnupg \ gnupg \
jq \ jq \

Wyświetl plik

@ -110,6 +110,7 @@ RUN \
locales && \ locales && \
echo "**** install packages ****" && \ echo "**** install packages ****" && \
apt-get install -y \ apt-get install -y \
cron \
curl \ curl \
gnupg \ gnupg \
jq \ jq \

Wyświetl plik

@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
for cron_user in abc root; do
if [[ -f "/defaults/crontabs/${cron_user}" ]]; then
# make folders
mkdir -p \
/config/crontabs
# if crontabs do not exist in config
if [[ ! -f "/config/crontabs/${cron_user}" ]]; then
# copy crontab from system
if crontab -l -u "${cron_user}" >/dev/null; then
crontab -l -u "${cron_user}" >"/config/crontabs/${cron_user}"
fi
# if crontabs still do not exist in config (were not copied from system)
# copy crontab from image defaults (using -n, do not overwrite an existing file)
cp -n "/defaults/crontabs/${cron_user}" /config/crontabs/
fi
# set permissions and import user crontabs
lsiown "${cron_user}":"${cron_user}" "/config/crontabs/${cron_user}"
crontab -u "${cron_user}" "/config/crontabs/${cron_user}"
fi
done

Wyświetl plik

@ -0,0 +1 @@
oneshot

Wyświetl plik

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-crontab-config/run

Wyświetl plik

@ -0,0 +1,15 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
if builtin command -v crontab >/dev/null && [[ -n "$(crontab -l -u abc)" || -n "$(crontab -l -u root)" ]]; then
if builtin command -v busybox >/dev/null && [[ $(busybox) =~ [[:space:]](crond)([,]|$) ]]; then
exec busybox crond -f -S -l 5
elif [[ -f /usr/bin/apt ]] && [[ -f /usr/sbin/cron ]]; then
exec /usr/sbin/cron -f -L 5
else
echo "**** cron not found ****"
sleep infinity
fi
else
sleep infinity
fi

Wyświetl plik

@ -0,0 +1 @@
longrun