Forward environment to cron via crontab file

This commit is contained in:
stratholme 2020-08-14 23:48:12 +02:00
parent 58fe0314a9
commit ef94550b64
4 changed files with 20 additions and 7 deletions

View file

@ -6,9 +6,7 @@ RUN \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD files/main.py /main.py ADD files/main.py /main.py
ADD files/entrypoint.sh /entrypoint.sh
ADD files/crontab.tpl /crontab.tpl
ADD files/crontab /etc/cron.d/assembly-cron ENTRYPOINT ["/entrypoint.sh"]
RUN chmod 0644 /etc/cron.d/assembly-cron
RUN crontab /etc/cron.d/assembly-cron
CMD ["cron", "-f"]

14
files/entrypoint.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# Create crontab with current environment variables
(
printenv
echo
cat /crontab.tpl
) > /etc/cron.d/assembly-cron
# Install crontab
crontab /etc/cron.d/assembly-cron
# Run cron daemon
exec cron -f

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# vim: sw=2:ts=2:noet
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
#### Assemble the Undead ##### #### Assemble the Undead #####
@ -55,8 +56,8 @@ smtp_from = os.getenv('SMTP_FROM')
smtp_user = os.getenv('SMTP_USER') smtp_user = os.getenv('SMTP_USER')
smtp_password = os.getenv('SMTP_PASSWORD') smtp_password = os.getenv('SMTP_PASSWORD')
mail_subject = os.getenv('MAIL_SUBJECT') mail_subject = os.getenv('MAIL_SUBJECT')
mail_header = os.getenv('MAIL_HEADER') mail_header = os.getenv('MAIL_HEADER').replace("\\n","\n")
mail_footer = os.getenv('MAIL_FOOTER') mail_footer = os.getenv('MAIL_FOOTER').replace("\\n","\n")
def main(args): def main(args):