2024-09-27 22:57:06 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-09-27 18:40:51 +00:00
|
|
|
# run this script daily to renew any letsencrypt certs that need renewing
|
|
|
|
# renew cert if it expires within 30 days
|
|
|
|
|
2024-09-27 19:18:56 +00:00
|
|
|
export LEGO_SERVER="{{ lego_acme_server }}/directory"
|
2024-09-27 18:40:51 +00:00
|
|
|
export LEGO_PATH="{{ __lego_base_dir }}/.lego"
|
2024-09-27 20:15:02 +00:00
|
|
|
export CLOUDFLARE_DNS_API_TOKEN="{{ lego_cloudflare_api_token }}"
|
2024-09-27 18:40:51 +00:00
|
|
|
|
|
|
|
{% for cert in lego_certificates %}
|
|
|
|
echo "$(date) checking for cert update for {{ ', '.join(cert.domains) }}."
|
2024-09-27 22:57:06 +00:00
|
|
|
{{ __lego_bin_file }} --email="{{ lego_acme_account_email }}" --domains {{ ' --domains '.join(cert.domains) }} --key-type="{{ lego_key_type }}" --dns="cloudflare" {{ '--dns.resolvers="' + lego_dns_resolvers | join(',') + '"' if lego_dns_resolvers | length > 0 else '' }} renew {{ '--run-hook="' + __lego_base_dir + '/bin/hook-' + cert.name + '.sh"' if cert.hook is defined else '' }} --days 30
|
2024-09-27 18:40:51 +00:00
|
|
|
|
|
|
|
{% endfor %}
|