summaryrefslogtreecommitdiff
path: root/dehydrated/cron.weekly/local-dehydrated
blob: 9e68459dad3c5387349d8831130c22efe433983b (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. fqdn=$(hostname --fqdn)
  8. if [ -n "$fqdn" ] && [ "$mailhost" != "$fqdn" ]; then
  9. extradomains=${extradomains:+$extradomains }$fqdn
  10. fi
  11. domain=$(hostname --domain)
  12. if [ -n "$domain" ] && [ "$mailhost" != "$domain" ] && [ "$fqdn" != "$domain" ]; then
  13. extradomains=${extradomains:+$extradomains }$domain
  14. fi
  15. mailname=$(cat /etc/mailname) || true
  16. if [ -n "$mailname" ] && [ "$mailhost" != "$mailname" ] && [ "$fqdn" != "$mailhost" ] && [ "$domain" != "$mailhost" ]; then
  17. extradomains=${extradomains:+$extradomains }$mailname
  18. fi
  19. if [ -n "$mailhost" ] && ! grep ^"$mailhost" /etc/dehydrated/domains.txt; then
  20. dehydrated --cron --domain "$mailhost $extradomains" --algo rsa
  21. fi
  22. # update certdomain certs
  23. dehydrated --cron "$@"