Skip to content

Commit 3cb02ae

Browse files
committed
show dkim dns records in bind format
1 parent 80d5dd9 commit 3cb02ae

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

bin/v-list-mail-domain-dkim-dns

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# info: list mail domain dkim dns records
3+
# options: USER DOMAIN [FORMAT]
4+
#
5+
# The function of obtaining domain dkim dns records for proper setup.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$2
15+
format=${3-shell}
16+
17+
# Includes
18+
source $VESTA/func/main.sh
19+
20+
# Json function
21+
json_list_dkim_dns() {
22+
echo '{'
23+
echo -e "\t\"_domainkey\": {"
24+
echo " \"TTL\": \"3600\","
25+
echo " \"TXT\": \"'t=y; o=~;'\""
26+
echo -e "\t},"
27+
echo -e "\n\t\"mail._domainkey\": {"
28+
echo " \"TTL\": \"3600\","
29+
echo " \"TXT\": \"'$pub'\""
30+
echo -e "\t}\n}"
31+
32+
}
33+
34+
# Shell function
35+
shell_list_dkim_dns() {
36+
echo "_domainkey 3600 IN TXT \"t=y; o=~;\""
37+
echo "mail._domainkey 3600 IN TXT \"k=rsa; p=$pub\""
38+
}
39+
40+
41+
#----------------------------------------------------------#
42+
# Verifications #
43+
#----------------------------------------------------------#
44+
45+
check_args '2' "$#" 'USER DOMAIN [FORMAT]'
46+
is_object_valid 'user' 'USER' "$user"
47+
is_object_valid 'mail' 'DOMAIN' "$domain"
48+
49+
50+
#----------------------------------------------------------#
51+
# Action #
52+
#----------------------------------------------------------#
53+
54+
# Check pub key
55+
if [ -e "$USER_DATA/mail/$domain.pub" ]; then
56+
pub=$(cat $USER_DATA/mail/$domain.pub | sed ':a;N;$!ba;s/\n/\\n/g')
57+
else
58+
pub="DKIM-SUPPORT-IS-NOT-ACTIVATED"
59+
fi
60+
61+
# Listing domains
62+
case $format in
63+
json) json_list_dkim_dns ;;
64+
plain) shell_list_dkim_dns ;;
65+
shell) shell_list_dkim_dns ;;
66+
*) check_args '1' '0' '[FORMAT]'
67+
esac
68+
69+
70+
#----------------------------------------------------------#
71+
# Vesta #
72+
#----------------------------------------------------------#
73+
74+
exit

0 commit comments

Comments
 (0)