Serghey Rodin 14 лет назад
Родитель
Сommit
62e5d3dc30

+ 3 - 0
bin/v_add_mail_domain

@@ -64,6 +64,9 @@ 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*
+mkdir $V_HOME/$user/mail/$domain
+chown $user:mail $V_HOME/$user/mail/$domain
+chmod 770 $V_HOME/$user/mail/$domain
 
 # Adding symlink
 ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/

+ 80 - 0
bin/v_delete_mail_domain

@@ -0,0 +1,80 @@
+#!/bin/bash
+# info: delete mail domain
+# options: user domain
+#
+# The function for deleting MAIL domain. By deleting it all accounts will
+# also be deleted.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+
+# 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 web system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+# Checking user is active
+is_user_suspended
+
+# Checking domain exist
+is_domain_valid 'mail'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Get domain values
+get_domain_values 'mail'
+accounts=$(wc -l $V_USERS/$user/mail/$domain|cut -f 1 -d ' ')
+
+rm -f /etc/exim/domains/$domain
+rm -rf $V_HOME/$user/conf/$domain
+rm -rf $V_HOME/$user/mail/$domain
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Delete domain config
+sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/mail.conf
+rm -f $V_USERS/$user/mail/$domain
+rm -f $V_USERS/$user/mail/$domain.pem
+rm -f $V_USERS/$user/mail/$domain.pub
+# autoreply
+
+# Decreasing domain value
+decrease_user_value "$user" '$U_MAIL_DOMAINS'
+decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts"
+
+# Logging
+cmd='"v_add_mail_domain'
+log_history "$V_EVENT" "$cmd $user $domain $ANTISPAM $ANTIVIRUS $DKIM"
+log_event 'system' "$V_EVENT"
+
+exit

+ 11 - 0
bin/v_rebuild_mail_domains

@@ -122,6 +122,17 @@ for domain in $domains; do
         fi
     fi
 
+    # Adding antispam protection
+    if [ "$SUSPENDED" != 'yes' ]; then
+        ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/
+    fi
+
+    if [ ! -e $V_HOME/$user/mail/$domain ]; then
+        mkdir $V_HOME/$user/mail/$domain
+    fi
+    chown $user:mail $V_HOME/$user/mail/$domain
+    chmod 770 $V_HOME/$user/mail/$domain
+
     # Rebuild counters
     U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1))
     U_DISK_MAIL=$((U_DISK_MAIL + U_DISK))

+ 69 - 0
bin/v_suspend_mail_domain

@@ -0,0 +1,69 @@
+#!/bin/bash
+# info: suspend mail domain
+# options: user domain
+#
+# The function suspends mail domain. 
+
+
+#----------------------------------------------------------#
+#                    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'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Deleting symbolic link
+rm -f /etc/exim/domains/$domain
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating config
+update_domain_value 'mail' '$SUSPENDED' 'yes'
+
+# Logging
+log_event 'system' "$V_EVENT"
+
+exit

+ 64 - 0
bin/v_suspend_mail_domains

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: suspend mail domains
+# options: user
+#
+# The function suspends all user's MAIL domains.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+
+# 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 '1' "$#" 'user'
+
+# Checking argument format
+format_validation 'user'
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config
+conf="$V_USERS/$user/mail.conf"
+
+# Defining fileds to select
+field='$DOMAIN'
+search_string="SUSPENDED='no'"
+domains=$(dom_clear_search)
+
+# Starting suspend loop
+for domain in $domains; do
+    $V_BIN/v_suspend_mail_domain "$user" "$domain"
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event 'system' "$V_EVENT"
+
+exit

+ 69 - 0
bin/v_unsuspend_mail_domain

@@ -0,0 +1,69 @@
+#!/bin/bash
+# info: unsuspend mail domain
+# options: user domain
+#
+# The function unsuspends mail domain. 
+
+
+#----------------------------------------------------------#
+#                    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_value_exist 'mail' '$SUSPENDED'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Add symbolic link
+ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating config
+update_domain_value 'mail' '$SUSPENDED' 'no'
+
+# Logging
+log_event 'system' "$V_EVENT"
+
+exit

+ 69 - 0
bin/v_unsuspend_mail_domains

@@ -0,0 +1,69 @@
+#!/bin/bash
+# info: unsuspend mail domains
+# options: user
+#
+# The function unsuspends all user's MAIL domains.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+
+# 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 '1' "$#" 'user'
+
+# Checking argument format
+format_validation 'user'
+
+# Checking dns system is enabled
+is_system_enabled 'MAIL_SYSTEM'
+
+# Checking user
+is_user_valid
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config
+conf="$V_USERS/$user/mail.conf"
+
+# Defining fileds to select
+field='$DOMAIN'
+
+# Defining search string
+search_string="SUSPENDED='yes'"
+
+# Parsing suspeneded domains
+domains=$(dom_clear_search)
+
+
+# Starting unsuspend loop
+for domain in $domains; do
+    $V_BIN/v_unsuspend_mail_domain "$user" "$domain"
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event 'system' "$V_EVENT"
+
+exit