Fix cron container: pass env vars to cron jobs
Alpine crond doesn't inherit the container environment, so OUTLINE_API_TOKEN and other vars were missing. Dump env at startup and source it in each cron entry.
This commit is contained in:
parent
8e7424ed05
commit
8514476030
2 changed files with 6 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Outline database + file backup — daily at 3 AM UTC
|
# Outline database + file backup — daily at 3 AM UTC
|
||||||
0 3 * * * /app/scripts/outline-backup.sh /backups/outline >> /var/log/outline-backup.log 2>&1
|
0 3 * * * . /etc/environment.sh; /app/scripts/outline-backup.sh /backups/outline >> /var/log/outline-backup.log 2>&1
|
||||||
|
|
||||||
# Wiki content export to git — daily at 4 AM UTC
|
# Wiki content export to git — daily at 4 AM UTC
|
||||||
0 4 * * * /app/scripts/export-content-cron.sh >> /var/log/wiki-export.log 2>&1
|
0 4 * * * . /etc/environment.sh; /app/scripts/export-content-cron.sh >> /var/log/wiki-export.log 2>&1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ cp /root/.ssh/* /root/.ssh_tmp/ 2>/dev/null || true
|
||||||
ssh-keyscan -t ed25519,rsa git.ghostguild.org >> /root/.ssh_tmp/known_hosts 2>/dev/null
|
ssh-keyscan -t ed25519,rsa git.ghostguild.org >> /root/.ssh_tmp/known_hosts 2>/dev/null
|
||||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/root/.ssh_tmp/known_hosts -i /root/.ssh/id_ed25519"
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/root/.ssh_tmp/known_hosts -i /root/.ssh/id_ed25519"
|
||||||
|
|
||||||
|
# Dump environment for cron jobs (crond doesn't inherit container env)
|
||||||
|
env | grep -v '^_=' | sed 's/^\(.*\)$/export \1/' > /etc/environment.sh
|
||||||
|
chmod 600 /etc/environment.sh
|
||||||
|
|
||||||
echo "Cron jobs loaded:"
|
echo "Cron jobs loaded:"
|
||||||
crontab -l
|
crontab -l
|
||||||
echo "Starting crond..."
|
echo "Starting crond..."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue