Merge pull request #475 from linuxserver/universal-cron-s6v3

switch to hybrid (universal-cron)
This commit is contained in:
aptalca 2022-08-30 12:17:29 -04:00 committed by GitHub
commit a614cef135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#!/usr/bin/with-contenv bash
if [ ! -f /usr/sbin/cron ] && [ -f /usr/bin/apt ]; then
echo "**** Adding cron to package install list ****"
echo "cron" >> /mod-repo-packages-to-install.list
else
echo "**** cron package already installed, skipping ****"
fi

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mod-universal-cron-add-package/run

View File

@ -0,0 +1,35 @@
#!/usr/bin/with-contenv bash
# make folders
mkdir -p \
/config/crontabs
# if root crontabs do not exist in config
if [[ ! -f /config/crontabs/root ]]; then
# copy root crontab from system
if crontab -l -u root; then
crontab -l -u root > /config/crontabs/root
fi
# if root crontabs still do not exist in config (were not copied from system)
# copy root crontab from included defaults (using -n, do not overwrite an existing file)
cp -n /defaults/crontabs-mod/root /config/crontabs/
fi
# if abc crontabs do not exist in config
if [[ ! -f /config/crontabs/abc ]]; then
# copy abc crontab from system
if crontab -l -u abc; then
crontab -l -u abc > /config/crontabs/abc
fi
# if abc crontabs still do not exist in config (were not copied from system)
# copy abc crontab from included defaults
cp -n /defaults/crontabs-mod/abc /config/crontabs/
fi
# import user crontabs
crontab -u root /config/crontabs/root
crontab -u abc /config/crontabs/abc

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mod-universal-cron-setup/run

View File

@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
if [ -f /usr/bin/apt ]; then
# ubuntu
exec /usr/sbin/cron -f -L 1
elif [ -f /sbin/apk ]; then
# alpine
exec /usr/sbin/crond -f -S -l 5
fi

View File

@ -0,0 +1 @@
longrun

0
root/etc/services.d/cron/run Normal file → Executable file
View File