diff --git a/bundles/cron/files/cron_template b/bundles/cron/files/cron_template new file mode 100644 index 0000000..81e7691 --- /dev/null +++ b/bundles/cron/files/cron_template @@ -0,0 +1,14 @@ +# __ ____ +# / /_ __ ______ ____/ / /__ _ ___________ _____ +# / __ \/ / / / __ \/ __ / / _ \ | /| / / ___/ __ `/ __ \ +# / /_/ / /_/ / / / / /_/ / / __/ |/ |/ / / / /_/ / /_/ / +#/_.___/\__,_/_/ /_/\__,_/_/\___/|__/|__/_/ \__,_/ .___/ +# /_/ +# +# CAUTION! This file is managed with bundlewrap. +# Any manual edits will be lost! + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +${cron} diff --git a/bundles/cron/files/crontab b/bundles/cron/files/crontab new file mode 100644 index 0000000..0c6b908 --- /dev/null +++ b/bundles/cron/files/crontab @@ -0,0 +1,17 @@ +# __ ____ +# / /_ __ ______ ____/ / /__ _ ___________ _____ +# / __ \/ / / / __ \/ __ / / _ \ | /| / / ___/ __ `/ __ \ +# / /_/ / /_/ / / / / /_/ / / __/ |/ |/ / / / /_/ / /_/ / +#/_.___/\__,_/_/ /_/\__,_/_/\___/|__/|__/_/ \__,_/ .___/ +# /_/ +# +# CAUTION! This file is managed with bundlewrap. +# Any manual edits will be lost! + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +${min} * * * * root cd / && run-parts --report /etc/cron.hourly +${min} 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) +${min} 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) +${min} 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) diff --git a/bundles/cron/items.py b/bundles/cron/items.py index 7170ffe..f6075f1 100644 --- a/bundles/cron/items.py +++ b/bundles/cron/items.py @@ -1,4 +1,11 @@ -files = {} +files = { + '/etc/crontab': { + 'content_type': 'mako', + 'context': { + 'min': (node.magic_number%60), + }, + }, +} directories = { '/etc/cron.d': { @@ -11,5 +18,9 @@ directories = { for crontab, content in node.metadata.get('cron', {}).items(): files['/etc/cron.d/{}'.format(crontab)] = { - 'content': content + "\n", + 'source': 'cron_template', + 'content_type': 'mako', + 'context': { + 'cron': content, + } } diff --git a/nodes/htz/ex42-1048908.py b/nodes/htz/ex42-1048908.py index 6f16e5b..82f412f 100644 --- a/nodes/htz/ex42-1048908.py +++ b/nodes/htz/ex42-1048908.py @@ -68,6 +68,12 @@ nodes['htz.ex42-1048908'] = { }, }, }, + 'cron': { + # TODO move to a proper bundle + 'backup': '0 1 * * * root /root/backup.sh', + 'restart_mautrix_whatsapp': '0 3 * * * root systemctl restart matrix-bridge-whatsapp.service', + 'telekom_nervkram': vault.decrypt('encrypt$gAAAAABfqXi23M96wrSLhqlbhqgePYX06LjPXfyQU2y_07kqYYLztj_PhS1-dk4r5FiiL2Ofmx5iCKW1sZNqiQSuHj2uKaitH0GnwHqj5CI2JwkAS9HrFxw=').format_into('0 0 * * * root date | mail -s \'daily test mail \' -r postmaster@mx0.kunbox.net {}'), + }, 'gitea': { 'version': '1.12.5', 'sha256': '8ed8bff1f34d8012cab92943214701c10764ffaca102e311a3297edbb8fce940',