summaryrefslogtreecommitdiff
path: root/dehydrated
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2018-10-20 10:10:05 +0200
committerJonas Smedegaard <dr@jones.dk>2018-10-20 10:10:05 +0200
commit9b200d881e43d0e2b4255a0f15aa3e5e1524a43a (patch)
tree9a7a9eaf5b917f7d886f8215f7e019e59489d7dc /dehydrated
parent1b0101fd285e4a1e8a74f232d03a6da31a94de03 (diff)
Tidy: Use if-then-fi (not confusing chain of fallbacks).
Diffstat (limited to 'dehydrated')
-rwxr-xr-xdehydrated/cron.weekly/local-dehydrated23
1 files changed, 12 insertions, 11 deletions
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 "$@"