#!/bin/bash # Print the DNS records this domain needs, read back from Stalwart rather than # composed here. # # The server keeps the whole set in the domain's `dnsZoneFile`, which means this # includes the live DKIM public keys — the one part nobody can write down in # advance, and the part people most often come looking for after install. # It also tracks reality: rotate a DKIM key and this shows the new one. appStalwartShowDns() { local domain_id zone domain_id=$(stalwart_cli query Domain 2>/dev/null | awk 'NR==2{print $1}') if [[ -z "$domain_id" ]]; then isError "Could not read the domain from Stalwart — is it running and set up?" return 1 fi zone=$(stalwart_cli get Domain "$domain_id" 2>/dev/null \ | sed -n '/DNS Zone File:/,$p' | sed 's/^ *DNS Zone File: *//') if [[ -z "$zone" ]]; then isError "Stalwart returned no zone data for this domain." return 1 fi local mail_host="${host_setup:-your-mail-hostname}" echo "" if [[ "$(stalwart_mode)" == "private" ]]; then isNotice "This server is private, so none of these need publishing today." isNotice "They are what you would add if you switched it to public." echo "" fi isNotice "DNS records for this mail server:" echo " A ${mail_host} ${public_ip_v4:-}" echo "" printf '%s\n' "$zone" | sed 's/^/ /' echo "" isNotice "The A and PTR records are set at your host and provider; the rest go in the zone." return 0 }