From 9b200d881e43d0e2b4255a0f15aa3e5e1524a43a Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 20 Oct 2018 10:10:05 +0200 Subject: Tidy: Use if-then-fi (not confusing chain of fallbacks). --- dehydrated/cron.weekly/local-dehydrated | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'dehydrated') diff --git a/dehydrated/cron.weekly/local-dehydrated b/dehydrated/cron.weekly/local-dehydrated index 24ca7e7..43ab94d 100755 --- a/dehydrated/cron.weekly/local-dehydrated +++ b/dehydrated/cron.weekly/local-dehydrated @@ -7,19 +7,20 @@ set -eu # update non-EC mailhost cert if resolvable and not a certdomain mailhost=$(cat /etc/local-REDPILL/$(cat /etc/local-ORG/realm)/mailhost) || true mailname=$(cat /etc/mailname) || true + fqdn=$(hostname --fqdn) -[ -z "$fqdn" ] \ - || [ "$mailhost" = "$fqdn" ] \ - || extradomains=${extradomains:+$extradomains }$fqdn +if [ -n "$fqdn" ] && [ "$mailhost" != "$fqdn" ]; then + extradomains=${extradomains:+$extradomains }$fqdn +fi + domain=$(hostname --domain) -[ -z "$domain" ] \ - || [ "$mailhost" = "$domain" ] \ - || [ "$fqdn" = "$domain" ] \ - || extradomains=${extradomains:+$extradomains }$domain -[ -z "$mailhost" ] \ - || [ "$mailhost" != "$mailname" ] \ - || grep ^"$mailhost" /etc/dehydrated/domains.txt \ - || dehydrated --cron --domain "$mailhost $extradomains" --algo rsa +if [ -n "$domain" ] && [ "$mailhost" != "$domain" ] && [ "$fqdn" != "$domain" ]; then + extradomains=${extradomains:+$extradomains }$domain +fi + +if [ -n "$mailhost" ] && [ "$mailhost" = "$mailname" ] && ! grep ^"$mailhost" /etc/dehydrated/domains.txt; then + dehydrated --cron --domain "$mailhost $extradomains" --algo rsa +fi # update certdomain certs dehydrated --cron "$@" -- cgit v1.2.3