Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

48 wiersze
1.6 KiB

  1. #!/bin/sh
  2. new_domain="$1"
  3. mail_service_domain="$2"
  4. # Check if both domains are provided
  5. [ -z "$new_domain" ] || [ -z "$mail_service_domain" ] && { echo "Usage: $0 new_domain mail_service_domain"; exit 1; }
  6. subdom="mail"
  7. maildomain="$subdom.$mail_service_domain"
  8. # Add the new domain to the valid postfix addresses.
  9. if ! grep -q "^mydestination.*$new_domain" /etc/postfix/main.cf; then
  10. sed -i "s/^mydestination.*/&, $new_domain/" /etc/postfix/main.cf
  11. fi
  12. # Create DKIM for the new domain.
  13. mkdir -p "/etc/postfix/dkim/$new_domain"
  14. opendkim-genkey -D "/etc/postfix/dkim/$new_domain" -d "$new_domain" -s "$subdom"
  15. chgrp -R opendkim /etc/postfix/dkim/*
  16. chmod -R g+r /etc/postfix/dkim/*
  17. # Add entries to keytable and signing table.
  18. echo "$subdom._domainkey.$new_domain $new_domain:$subdom:/etc/postfix/dkim/$new_domain/$subdom.private" >> /etc/postfix/dkim/keytable
  19. echo "*@$new_domain $subdom._domainkey.$new_domain" >> /etc/postfix/dkim/signingtable
  20. systemctl reload opendkim postfix
  21. # Print out DKIM TXT entry.
  22. pval="$(tr -d '\n' <"/etc/postfix/dkim/$new_domain/$subdom.txt" | sed sed "s/k=rsa.* \"p=/k=rsa; p=/;s/\"\s*\"//;s/\"\s*).*//" | grep -o 'p=.*')"
  23. dkimentry="$subdom._domainkey.$new_domain TXT v=DKIM1; k=rsa; $pval"
  24. dmarcentry="_dmarc.$new_domain TXT v=DMARC1; p=reject; rua=mailto:dmarc@$new_domain; fo=1"
  25. spfentry="$new_domain TXT v=spf1 mx a:$maildomain -all"
  26. mxentry="$new_domain MX 10 $maildomain"
  27. echo "$dkimentry
  28. $dmarcentry
  29. $spfentry
  30. $mxentry" >> "$HOME/dns_emailwizard_added"
  31. echo "=== ADD THE FOLLOWING TO YOUR DNS TXT RECORDS ==="
  32. echo "$dkimentry
  33. $dmarcentry
  34. $spfentry
  35. $mxentry"
  36. echo "They have also been stored in $HOME/dns_emailwizard_added"