Explorar o código

show dkim dns records in bind format

Serghey Rodin %!s(int64=12) %!d(string=hai) anos
pai
achega
3cb02aec9d
Modificáronse 1 ficheiros con 74 adicións e 0 borrados
  1. 74 0
      bin/v-list-mail-domain-dkim-dns

+ 74 - 0
bin/v-list-mail-domain-dkim-dns

@@ -0,0 +1,74 @@
+#!/bin/bash
+# info: list mail domain dkim dns records
+# options: USER DOMAIN [FORMAT]
+#
+# The function of obtaining domain dkim dns records for proper setup.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+format=${3-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# Json function
+json_list_dkim_dns() {
+    echo '{'
+    echo -e "\t\"_domainkey\": {"
+    echo "        \"TTL\": \"3600\","
+    echo "        \"TXT\": \"'t=y; o=~;'\""
+    echo -e "\t},"
+    echo -e "\n\t\"mail._domainkey\": {"
+    echo "        \"TTL\": \"3600\","
+    echo "        \"TXT\": \"'$pub'\""
+    echo -e "\t}\n}"
+
+}
+
+# Shell function
+shell_list_dkim_dns() {
+    echo "_domainkey      3600    IN    TXT    \"t=y; o=~;\""
+    echo "mail._domainkey 3600    IN    TXT    \"k=rsa; p=$pub\""
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER DOMAIN [FORMAT]'
+is_object_valid 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Check pub key
+if [ -e "$USER_DATA/mail/$domain.pub" ]; then
+    pub=$(cat $USER_DATA/mail/$domain.pub | sed ':a;N;$!ba;s/\n/\\n/g')
+else
+    pub="DKIM-SUPPORT-IS-NOT-ACTIVATED"
+fi
+
+# Listing domains
+case $format in
+    json)   json_list_dkim_dns ;;
+    plain)  shell_list_dkim_dns ;;
+    shell)  shell_list_dkim_dns ;;
+    *)      check_args '1' '0' '[FORMAT]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit