summaryrefslogtreecommitdiff
path: root/dehydrated/cron.weekly/local-dehydrated
blob: 861169fed5baf9249fdf4f2d82c6f34775e7c1ab (plain)
  1. #!/bin/sh
  2. #
  3. # Renew letsencrypt certificates
  4. set -eu
  5. REALM=$(cat /etc/local-ORG/realm) || true
  6. # update non-EC mailhost cert if resolvable and not a certdomain
  7. mailhost=$(cat "/etc/local-REDPILL/$REALM/mailhost") || true
  8. mailname=$(cat /etc/mailname) || true
  9. fqdn=$(hostname --fqdn)
  10. if [ -n "$fqdn" ] && [ "$mailhost" != "$fqdn" ]; then
  11. extradomains=${extradomains:+$extradomains }$fqdn
  12. fi
  13. domain=$(hostname --domain)
  14. if [ -n "$domain" ] && [ "$mailhost" != "$domain" ] && [ "$fqdn" != "$domain" ]; then
  15. extradomains=${extradomains:+$extradomains }$domain
  16. fi
  17. if [ -n "$mailhost" ] && [ "$mailhost" = "$mailname" ] && ! grep ^"$mailhost" /etc/dehydrated/domains.txt; then
  18. dehydrated --cron --domain "$mailhost $extradomains" --algo rsa
  19. fi
  20. # update certdomain certs
  21. dehydrated --cron "$@"