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