浏览代码

completed about 20% of email api

Serghey Rodin 14 年之前
父节点
当前提交
8f6fbfc0e8

+ 1 - 0
bin/v_add_dns_domain_record

@@ -87,6 +87,7 @@ echo "$dns_rec" >> $zone
 sort_dns_records 
 
 # Updating zone
+conf="$V_HOME/$user/conf/dns/$domain.db"
 update_domain_zone
 
 

+ 56 - 52
bin/v_add_mail_domain

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: add mail domain
-# options: user domain [antispam] [antivirus]
+# options: user domain [antispam] [antivirus] [dkim] [dkim_size]
 #
 # The function adds MAIL domain.
 
@@ -15,7 +15,9 @@ domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain_idn=$(idn -t --quiet -a "$domain")
 antispam=${3-yes}
-antivirus=${3-yes}
+antivirus=${4-yes}
+dkim=${5-yes}
+dkim_size=${6-512}
 
 # Importing variables
 source $VESTA/conf/vars.conf
@@ -29,10 +31,10 @@ source $V_FUNC/domain.func
 #----------------------------------------------------------#
 
 # Checking arg number
-check_args '2' "$#" 'user domain [antispam] [antivirus]'
+check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]'
 
 # Checking argument format
-format_validation 'user' 'domain' 'antispam' 'antivirus'
+format_validation 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
 
 # Checking dns system is enabled
 is_system_enabled 'MAIL_SYSTEM'
@@ -50,56 +52,61 @@ is_domain_new 'mail'
 is_package_full 'MAIL_DOMAINS'
 
 
-exit
-
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
 
-# Defining variables
-i=1
-ns=$(get_user_value '$NS')
-for nameserver in ${ns//,/ };do
-    eval ns$i=$nameserver
-    i=$((i + 1))
-done
+# Adding domain directory
+mkdir $V_HOME/$user/conf/mail/$domain
+touch $V_HOME/$user/conf/mail/$domain/aliases
+touch $V_HOME/$user/conf/mail/$domain/protection
+touch $V_HOME/$user/conf/mail/$domain/passwd
+chown -R root:mail $V_HOME/$user/conf/mail/$domain
+chmod 770 $V_HOME/$user/conf/mail/$domain
+chmod 660 $V_HOME/$user/conf/mail/$domain*
+
+# Adding antispam protection
+if [ "$antispam" = 'yes' ]; then
+    echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection
+fi
+
+# Adding antivirus protection
+if [ "$antivirus" = 'yes' ]; then
+    echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
+fi
 
-if [ -z "$soa" ]; then
-    soa="$ns1"
+# Adding dkim
+if [ "$dkim" = 'yes' ]; then
+    openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null
+    openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \
+        -out $V_USERS/$user/mail/$domain.pub 2>/dev/null
+    chmod 660 $V_USERS/$user/mail/$domain.*
+
+    cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem
+    chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem
+    chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem
+
+    # Adding dkim dns records
+    check_dns_domain=$(is_domain_valid 'dns')
+    if [ "$?" -eq 0 ]; then
+        p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
+        record='_domainkey'
+        policy="\"t=y; o=~;\""
+        $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
+
+        record='mail._domainkey'
+        selector="\"k=rsa\; p=$p\""
+        $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
+    fi
 fi
 
-# Adding zone to dns dir
-cat $V_DNSTPL/$template.tpl |\
-    sed -e "s/%ip%/$ip/g" \
-        -e "s/%domain_idn%/$domain_idn/g" \
-        -e "s/%domain%/$domain/g" \
-        -e "s/%ns1%/$ns1/g" \
-        -e "s/%ns2%/$ns2/g" \
-        -e "s/%ns3%/$ns3/g" \
-        -e "s/%ns4%/$ns4/g" \
-        -e "s/%ns5%/$ns5/g" \
-        -e "s/%ns6%/$ns6/g" \
-        -e "s/%ns7%/$ns7/g" \
-        -e "s/%ns8%/$ns8/g" \
-        -e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain
-
-# Adding dns.conf record
-dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
-dns_rec="$dns_rec SOA='$soa' SUSPENDED='no' DATE='$V_DATE'"
-echo "$dns_rec" >> $V_USERS/$user/dns.conf
-chmod 660 $V_USERS/$user/dns.conf
-
-# Adding zone in named.conf
-named="zone \"$domain_idn\" {type master; file"
-named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};"
-echo "$named" >> /etc/named.conf
-
-# Updating domain dns zone
-conf="$V_HOME/$user/conf/dns/$domain.db"
-update_domain_zone
-
-chmod 640 $conf
-chown root:named $conf
+# Adding domain to vesta db
+s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'"
+s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' DATE='$V_DATE'"
+echo $s >> $V_USERS/$user/mail.conf
+touch $V_USERS/$user/mail/$domain
+chmod 660 $V_USERS/$user/mail.conf
+chmod 660 $V_USERS/$user/mail/$domain
 
 
 #----------------------------------------------------------#
@@ -107,13 +114,10 @@ chown root:named $conf
 #----------------------------------------------------------#
 
 # Increasing domain value
-increase_user_value "$user" '$U_DNS_DOMAINS'
-
-# Adding task to the vesta pipe
-restart_schedule 'dns'
+increase_user_value "$user" '$U_MAIL_DOMAINS'
 
 # Logging
-log_history "$V_EVENT" "v_delete_dns_domain $user $domain"
+log_history "$V_EVENT" "v_delete_mail_domain $user $domain"
 log_event 'system' "$V_EVENT"
 
 exit

+ 74 - 0
bin/v_add_mail_domain_antispam

@@ -0,0 +1,74 @@
+#!/bin/bash
+# info: add mail domain antispam support
+# options: user domain
+#
+# The function enables spamassasin for incomming emails.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '2' "$#" 'user domain'
+
+# Checking argument format
+format_validation 'user' 'domain'
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+# Checking user is active
+is_user_suspended
+
+# Checking domain
+is_domain_valid 'mail'
+
+# Checking domain is not suspened
+is_domain_suspended 'mail'
+
+# Checking errorlog is not added
+is_domain_key_empty 'mail' '$ANTISPAM'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding antispam key to config
+if [ -z "$(grep 'antispam' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
+    echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection
+fi
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Adding antispam in config
+update_domain_value 'mail' '$ANTISPAM' 'yes'
+
+# Logging
+log_history "$V_EVENT" "v_delete_mail_domain_antispam $user $domain"
+log_event 'system' "$V_EVENT"
+
+exit

+ 74 - 0
bin/v_add_mail_domain_antivirus

@@ -0,0 +1,74 @@
+#!/bin/bash
+# info: add mail domain antivirus support
+# options: user domain
+#
+# The function enables clamav for incomming emails.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '2' "$#" 'user domain'
+
+# Checking argument format
+format_validation 'user' 'domain'
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+# Checking user is active
+is_user_suspended
+
+# Checking domain
+is_domain_valid 'mail'
+
+# Checking domain is not suspened
+is_domain_suspended 'mail'
+
+# Checking errorlog is not added
+is_domain_key_empty 'mail' '$ANTIVIRUS'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding antispam key to config
+if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
+    echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
+fi
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Adding antispam in config
+update_domain_value 'mail' '$ANTIVIRUS' 'yes'
+
+# Logging
+log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain"
+log_event 'system' "$V_EVENT"
+
+exit

+ 76 - 0
bin/v_add_mail_domain_cactchall

@@ -0,0 +1,76 @@
+#!/bin/bash
+# info: add mail domain catchall account
+# options: user domain email
+#
+# The function enables catchall account for incomming emails. 
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+email="$3"
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '3' "$#" 'user domain email'
+
+# Checking argument format
+format_validation 'user' 'domain' 'email'
+exit
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+# Checking user is active
+is_user_suspended
+
+# Checking domain
+is_domain_valid 'mail'
+
+# Checking domain is not suspened
+is_domain_suspended 'mail'
+
+# Checking errorlog is not added
+is_domain_key_empty 'mail' '$ANTIVIRUS'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding antispam key to config
+if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
+    echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
+fi
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Adding antispam in config
+update_domain_value 'mail' '$ANTIVIRUS' 'yes'
+
+# Logging
+log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain"
+log_event 'system' "$V_EVENT"
+
+exit

+ 96 - 0
bin/v_add_mail_domain_dkim

@@ -0,0 +1,96 @@
+#!/bin/bash
+# info: add mail domain dkim support
+# options: user domain [dkim_size]
+#
+# The function adds DKIM signature to outgoing domain emails.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+dkim_size=${3-512}
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_CONF/vesta.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '2' "$#" 'user domain [dkim_size]'
+
+# Checking argument format
+format_validation 'user' 'domain' 'dkim_size'
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+# Checking user is active
+is_user_suspended
+
+# Checking domain
+is_domain_valid 'mail'
+
+# Checking domain is not suspened
+is_domain_suspended 'mail'
+
+# Checking errorlog is not added
+is_domain_key_empty 'mail' '$DKIM'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Generating dkim
+openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null
+openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \
+    -out $V_USERS/$user/mail/$domain.pub 2>/dev/null
+chmod 660 $V_USERS/$user/mail/$domain.*
+
+# Adding dkim to config
+cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem
+chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem
+chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem
+
+# Checking dns domain
+check_dns_domain=$(is_domain_valid 'dns')
+if [ "$?" -eq 0 ]; then
+    # Adding dkim dns records
+    p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
+    record='_domainkey'
+    policy="\"t=y; o=~;\""
+    $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
+
+    record='mail._domainkey'
+    selector="\"k=rsa\; p=$p\""
+    $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Adding dkim in config
+update_domain_value 'mail' '$DKIM' 'yes'
+
+# Logging
+log_history "$V_EVENT" "v_delete_mail_domain_dkim $user $domain"
+log_event 'system' "$V_EVENT"
+
+exit

+ 9 - 2
bin/v_change_dns_domain_tpl

@@ -65,15 +65,22 @@ ns2=$(get_user_value '$NS2')
 
 # Changing tpl
 update_domain_value 'dns' '$TPL' "$template"
-
 cat $V_DNSTPL/$template.tpl |\
     sed -e "s/%ip%/$ip/g" \
         -e "s/%domain_idn%/$domain_idn/g" \
         -e "s/%domain%/$domain/g" \
         -e "s/%ns1%/$ns1/g" \
-        -e "s/%ns2%/$ns2/g" > $V_USERS/$user/dns/$domain
+        -e "s/%ns2%/$ns2/g" \
+        -e "s/%ns3%/$ns3/g" \
+        -e "s/%ns4%/$ns4/g" \
+        -e "s/%ns5%/$ns5/g" \
+        -e "s/%ns6%/$ns6/g" \
+        -e "s/%ns7%/$ns7/g" \
+        -e "s/%ns8%/$ns8/g" \
+        -e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain
 
 # Updating zone
+conf="$V_HOME/$user/conf/dns/$domain.db"
 update_domain_zone
 
 

+ 115 - 0
bin/v_list_mail_domain

@@ -0,0 +1,115 @@
+#!/bin/bash
+# info: list web domain
+# options: user domain [format]
+#
+# The function of obtaining the list of domain parameters. This call, just as
+# all v_list_* calls, supports 3 formats - json, shell and plain.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+format=${3-shell}
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+# Json function
+json_list_domain() {
+    i=1
+    fileds_count=$(echo "$fields" | wc -w)
+    line=$(grep "DOMAIN='$domain'" $conf)
+
+    # Print top bracket
+    echo '{'
+
+    # Assing key=value
+    eval $line
+
+    # Starting output loop
+    for field in $fields; do
+        # Parsing key=value
+        eval value=$field
+
+        # Checking first field
+        if [ "$i" -eq 1 ]; then
+            echo -e "\t\"$value\": {"
+        else
+            if [ "$fileds_count" -eq "$i" ]; then
+                echo -e "\t\t\"${field//$/}\": \"$value\","
+            else
+                echo -e "\t\t\"${field//$/}\": \"$value\""
+            fi
+        fi
+        # Updating iterator
+        (( ++i))
+    done
+
+    # If there was any output
+    if [ -n "$value" ]; then
+        echo -e '        }'
+    fi
+    # Printing bottom json bracket
+    echo -e "}"
+}
+
+# Shell function
+shell_list_domain() {
+    line=$(grep "DOMAIN='$domain'" $conf)
+
+    # Parsing key=value
+    eval $line
+
+    # Print result line
+    for field in $fields; do
+        eval key="$field"
+        echo "${field//$/}: $key "
+    done
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking args
+check_args '2' "$#" 'user domain [format]'
+
+# Checking user
+is_user_valid
+
+# Checking domain exist
+is_domain_valid 'web'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config
+conf=$V_USERS/$user/mail.conf
+
+# Defining fileds to select
+fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL
+$SUSPENDED $DATE'
+
+# Listing domains
+case $format in 
+    json)   json_list_domain ;;
+    plain)  nohead=1; shell_list_domain ;;
+    shell)  shell_list_domain |column -t ;;
+    *)      check_args '2' '0' 'user domain [format]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 80 - 0
bin/v_list_mail_domain_dkim

@@ -0,0 +1,80 @@
+#!/bin/bash
+# info: list mail domain dkim
+# options: user domain [format]
+#
+# The function of obtaining domain dkim files.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+format=${3-shell}
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_FUNC/shared.func
+source $V_FUNC/domain.func
+
+# Json function
+json_list_ssl() {
+    echo '{'
+    echo -e "\t\"$domain\": {"
+    echo "        \"PEM\": \"$pem\","
+    echo "        \"PUB\": \"$pub\","
+    echo -e "\t}\n}"
+}
+
+# Shell function
+shell_list_ssl() {
+    if [ ! -z "$pem" ]; then
+        echo -e "$pem"
+    fi
+    if [ ! -z "$pub" ]; then
+        echo -e "\n$pub"
+    fi
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking args
+check_args '2' "$#" 'user domain [format]'
+
+# Checking user
+is_user_valid
+
+# Checking domain exist
+is_domain_valid 'mail'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+if [ -e "$V_USERS/$user/mail/$domain.pem" ]; then
+    pem=$(cat $V_USERS/$user/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g')
+fi
+
+if [ -e "$V_USERS/$user/mail/$domain.pub" ]; then
+    pub=$(cat $V_USERS/$user/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g')
+fi
+
+# Listing domains
+case $format in
+    json)   json_list_ssl ;;
+    plain)  nohead=1; shell_list_ssl ;;
+    shell)  shell_list_ssl ;;
+    *)      check_args '1' '0' '[format]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 60 - 0
bin/v_list_mail_domains

@@ -0,0 +1,60 @@
+#!/bin/bash
+# info: list mail domains
+# options user [format]
+#
+# The function of obtaining the list of all user domains.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+format=${2-shell}
+
+# Importing variables
+source $VESTA/conf/vars.conf
+source $V_FUNC/shared.func
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking args
+check_args '1' "$#" 'user [format]'
+
+# Checking argument format
+format_validation 'user'
+
+# Checking user
+is_user_valid
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config
+conf=$V_USERS/$user/mail.conf
+
+# Defining fileds to select
+fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL"
+fields="$fields \$SUSPENDED \$DATE"
+
+# Listing domains
+case $format in 
+    json)   json_list ;;
+    plain)  nohead=1; shell_list ;;
+    shell) fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $DATE';
+            shell_list | column -t ;;
+    *)      check_args '1' '0' 'user [format]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 6 - 6
func/domain.func

@@ -1,19 +1,19 @@
 # Checking domain existance
 is_domain_new() {
     config_type="$1"
-    dom=${2-domain}
+    dom=${2-$domain}
     check_all=$(grep -w $dom $V_USERS/*/*.conf)
     if [ ! -z "$check_all" ]; then
         check_ownership=$(grep -w $dom $V_USERS/$user/*.conf)
         if [ ! -z "$check_ownership" ]; then
             check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf)
             if [ ! -z "$check_type" ]; then
-                echo "Error: $dom exist"
+                echo "Error: domain $dom exist"
                 log_event 'debug' "$E_EXISTS $V_EVENT"
                 exit $E_EXISTS
             fi
         else
-            echo "Error: $dom exist"
+            echo "Error: domain $dom exist"
             log_event 'debug' "$E_EXISTS $V_EVENT"
             exit $E_EXISTS
         fi
@@ -26,7 +26,7 @@ is_domain_valid() {
 
     # Checking result
     if [ -z "$check_domain" ]; then
-        echo "Error: domain not exist"
+        echo "Error: domain $domain not exist"
         log_event 'debug' "$E_NOTEXIST $V_EVENT"
         exit $E_NOTEXIST
     fi
@@ -111,7 +111,7 @@ update_domain_zone() {
 
         # Converting utf records to ascii
         RECORD=$(idn --quiet -a -t "$RECORD")
-        VALUE=$(idn --quiet -a -t "$VALUE")
+        #VALUE=$(idn --quiet -a -t "$VALUE")
         eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
     done < $V_USERS/$user/dns/$domain
 }
@@ -313,7 +313,7 @@ is_domain_key_empty() {
 
     # Checkng key
     if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
-        echo "Error: value is not empty = $value"
+        echo "Error: ${key//$} is not empty = $value"
         log_event 'debug' "$E_EXISTS $V_EVENT"
         exit $E_EXISTS
     fi

+ 25 - 3
func/shared.func

@@ -329,6 +329,26 @@ format_validation() {
         fi
     }
 
+    # Defining format_bit function
+    format_bit() {
+        val="$1"
+        case $val in 
+            128) known='yes';;
+            256) known='yes';;
+            512) known='yes';;
+            768) known='yes';;
+            1024) known='yes';;
+            2048) known='yes';;
+            *)  known='no';;
+        esac
+
+        if [[ "$known" != 'yes' ]]; then
+            echo "Error: $var is out of range"
+            log_event 'debug' "$E_INVALID $V_EVENT"
+            exit $E_INVALID
+        fi
+    }
+
     # Defining format_ext function
     format_ext() {
         val="$1"
@@ -375,14 +395,15 @@ format_validation() {
         case $var in
             antispam)           format_bool "$v" ;;
             antivirus)          format_bool "$v" ;;
-            dom_alias)          format_dom "$v" ;;
             auth_pass)          format_pwd "$v" ;;
             auth_user)          format_usr "$v" ;;
-            ssl)                format_usr "$v" ;;
-            domain)             format_dom "$v" ;;
             database)           format_db  "$v" ;;
             day)                format_mhd "$v" ;;
             db_user)            format_dbu "$v" ;;
+            domain)             format_dom "$v" ;;
+            dom_alias)          format_dom "$v" ;;
+            dkim)               format_bool "$v" ;;
+            dkim_size)          format_bit "$v" ;;
             dvalue)             format_dvl "$v" ;;
             fname)              format_usr "$v" ;;
             job)                format_int "$v" ;;
@@ -415,6 +436,7 @@ format_validation() {
             password)           format_pwd "$v" ;;
             port)               format_int "$v" ;;
             rtype)              format_rcd "$v" ;;
+            ssl)                format_usr "$v" ;;
             shell)              format_sh  "$v" ;;
             soa)                format_dom "$v" ;;
             suspend_url)        format_url "$v" ;;