No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

etc_cron-monthly_letsencrypt-renew 883B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. set -o errexit
  3. # Renew all live certificates with LetsEncrypt. This needs to run at least
  4. # once every three months.
  5. # Given a certificate file returns "domain1,domain2"
  6. # https://community.letsencrypt.org/t/help-me-understand-renewal-config/7115
  7. function getDomains() {
  8. openssl x509 -text -in "$1" |
  9. grep -A1 "Subject Alternative Name:" | tail -n1 |
  10. tr -d ' ' | tr -d 'DNS:'
  11. }
  12. service apache2 stop
  13. for c in $(find /etc/letsencrypt/live/ -mindepth 1 -type d); do
  14. domains=$(getDomains "$c"/cert.pem)
  15. /root/letsencrypt/letsencrypt-auto --renew certonly -c /etc/letsencrypt/cli.conf --domains=$domains
  16. done
  17. service apache2 start
  18. # Services that rely on LE certificates may need restarted and/or other actions.
  19. for script in $(find /etc/letsencrypt/postrenew/ -maxdepth 1 -type f -executable); do
  20. echo "Executing ${script}."
  21. $script
  22. done