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