cron init

This commit is contained in:
Dominik Chilla 2020-03-23 00:44:44 +01:00
parent ba3be527e9
commit 4f1a83303b
3 changed files with 39 additions and 1 deletions

View File

@ -7,7 +7,15 @@ ADD ./snippets/acme/config /dehydrated/config
ADD ./snippets/acme/get_cert_ddns01.sh /app/get_cert_ddns01.sh
ADD ./snippets/acme/zwackl_hook.sh /app/zwackl_hook.sh
```
**Do not forget to include the crond-snippet!**
**Do not forget to include the cron snippet!**
## Cronjob
`/etc/periodic/daily/acme`:
```
#!/bin/bash
. /cron_env && /dehydrated/dehydrated --cron -t dns-01 -k /app/zwackl_hook.sh && ${ACME_RELOAD_CMD}
```
## Environment
* ACME_FQDNS (required)

1
cron/README.md Normal file
View File

@ -0,0 +1 @@
# env4cron

29
cron/start_cron.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
if [ ! -z "${CROND_ENABLE+x}" ]; then
# serialize ENV for cron-jobs
TMP_FILE=/tmp/cron_env
OUT_FILE=/cron_env
echo -n '' > "${OUT_FILE}"
env > "${TMP_FILE}"
while read -r line; do
echo "${line}" | grep -q "^PWD="
if [ $? = 0 ]; then
continue
fi
echo "${line}" | grep -q "\s"
if [ $? = 0 ]; then
# double-quote blank separated values for $(export)
# 1. awk: replace first(!) appearance of = with ="
# 2. awk: replace end of line with double-quotes
QUOTED=$(echo "${line}" | awk '{sub(/=/,"=\"");}1'| awk '{sub(/$/,"\"");}1')
echo "export ${QUOTED}" >> "${OUT_FILE}"
else
echo "export ${line}" >> "${OUT_FILE}"
fi
done <"${TMP_FILE}"
unlink "${TMP_FILE}"
# start crond in background
/usr/sbin/crond -b -S
fi