Skip to content

Commit 3e60f97

Browse files
author
Kristan Kenney
committed
Ensure DNS record for webmail is created
1 parent 814993a commit 3e60f97

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bin/v-add-webmail

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ is_object_unsuspended 'mail' 'DOMAIN' "$domain"
5454
# Action #
5555
#----------------------------------------------------------#
5656

57+
# Ensure DNS record exists if Hestia is hosting DNS zones
58+
if [ ! -z "$DNS_SYSTEM" ]; then
59+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
60+
webmail_record=$($BIN/v-list-dns-records $user $domain | grep -i $WEBMAIL_ALIAS | cut -d' ' -f1)
61+
62+
if [ "$dns_domain" = "$domain" ]; then
63+
if [ -z "$webmail_record" ]; then
64+
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
65+
else
66+
$BIN/v-delete-dns-record $user $domain $webmail_record
67+
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
68+
fi
69+
fi
70+
fi
71+
5772
# Add webmail configuration to mail domain
5873
WEBMAIL_TEMPLATE="default"
5974
if [ "$WEB_SYSTEM" = "nginx" ]; then

0 commit comments

Comments
 (0)