docker-swag/root/etc/s6-overlay/s6-rc.d/init-crontabs-config/run

39 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-01-21 04:42:13 +00:00
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
2023-03-02 19:21:27 +00:00
# make folders
mkdir -p \
/config/crontabs
2023-01-21 04:42:13 +00:00
2023-03-02 19:21:27 +00:00
## root
# if crontabs do not exist in config
2023-01-21 04:42:13 +00:00
if [[ ! -f /config/crontabs/root ]]; then
2023-03-02 19:21:27 +00:00
# copy crontab from system
if crontab -l -u root; then
crontab -l -u root >/config/crontabs/root
fi
2023-01-21 04:42:13 +00:00
2023-03-02 19:21:27 +00:00
# if crontabs still do not exist in config (were not copied from system)
# copy crontab from included defaults (using -n, do not overwrite an existing file)
cp -n /etc/crontabs/root /config/crontabs/ 2> >(grep -v 'cp: not replacing')
2023-01-26 01:42:05 +00:00
fi
2023-03-02 19:21:27 +00:00
# set permissions and import user crontabs
lsiown root:root /config/crontabs/root
crontab -u root /config/crontabs/root
2023-01-26 01:42:05 +00:00
2023-03-02 19:21:27 +00:00
## abc
# if crontabs do not exist in config
2023-01-26 01:42:05 +00:00
if [[ ! -f /config/crontabs/abc ]]; then
2023-03-02 19:21:27 +00:00
# copy crontab from system
if crontab -l -u abc; then
crontab -l -u abc >/config/crontabs/abc
fi
2023-01-26 01:42:05 +00:00
2023-03-02 19:21:27 +00:00
# if crontabs still do not exist in config (were not copied from system)
# copy crontab from included defaults (using -n, do not overwrite an existing file)
cp -n /etc/crontabs/abc /config/crontabs/ 2> >(grep -v 'cp: not replacing')
2023-03-02 19:21:27 +00:00
fi
# set permissions and import user crontabs
lsiown abc:abc /config/crontabs/abc
2023-01-26 01:42:05 +00:00
crontab -u abc /config/crontabs/abc