mail api 40% completed

This commit is contained in:
Serghey Rodin 2012-02-24 11:35:43 +02:00
parent 9e0bc28dfc
commit b05944f5a4
7 changed files with 245 additions and 12 deletions

View file

@ -65,6 +65,9 @@ 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 symlink
ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/
# Adding antispam protection
if [ "$antispam" = 'yes' ]; then
echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection

View file

@ -2,7 +2,7 @@
# info: add mail domain antivirus support
# options: user domain
#
# The function enables clamav for incomming emails.
# The function enables clamav scan for incomming emails.
#----------------------------------------------------------#
@ -47,7 +47,7 @@ is_domain_valid 'mail'
# Checking domain is not suspened
is_domain_suspended 'mail'
# Checking errorlog is not added
# Checking current value
is_domain_key_empty 'mail' '$ANTIVIRUS'
@ -55,7 +55,7 @@ is_domain_key_empty 'mail' '$ANTIVIRUS'
# Action #
#----------------------------------------------------------#
# Adding antispam key to config
# Adding antivirus 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
@ -64,7 +64,7 @@ fi
# Vesta #
#----------------------------------------------------------#
# Adding antispam in config
# Adding antivirus in config
update_domain_value 'mail' '$ANTIVIRUS' 'yes'
# Logging

View file

@ -32,7 +32,6 @@ 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'
@ -50,27 +49,27 @@ is_domain_valid 'mail'
is_domain_suspended 'mail'
# Checking errorlog is not added
is_domain_key_empty 'mail' '$ANTIVIRUS'
is_domain_key_empty 'mail' '$CATCHALL'
#----------------------------------------------------------#
# 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
# Adding catchall alias
sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding antispam in config
update_domain_value 'mail' '$ANTIVIRUS' 'yes'
update_domain_value 'mail' '$CATCHALL' "$email"
# Logging
log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain"
log_history "$V_EVENT" "v_delete_mail_domain_catchall $user $domain"
log_event 'system' "$V_EVENT"
exit

View file

@ -63,6 +63,7 @@ fi
sort_dns_records
# Updating zone
conf="$V_HOME/$user/conf/dns/$domain.db"
update_domain_zone

View file

@ -0,0 +1,73 @@
#!/bin/bash
# info: delete mail domain antispam support
# options: user domain
#
# The function disable 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 current value
is_domain_value_exist 'mail' '$ANTISPAM'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Delete antispam key
sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Delete antispam in config
update_domain_value 'mail' '$ANTISPAM' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_antispam $user $domain"
log_event 'system' "$V_EVENT"
exit

View file

@ -0,0 +1,73 @@
#!/bin/bash
# info: delete mail domain antivirus support
# options: user domain
#
# The function disables clamav scan 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 current value
is_domain_value_exist 'mail' '$ANTIVIRUS'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Delete antivirus key
sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Delete antivirus in config
update_domain_value 'mail' '$ANTIVIRUS' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_antivirus $user $domain"
log_event 'system' "$V_EVENT"
exit

84
bin/v_delete_mail_domain_dkim Executable file
View file

@ -0,0 +1,84 @@
#!/bin/bash
# info: delete mail domain dkim support
# options: user domain [dkim_size]
#
# The function delete DKIM domain pem.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
# 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_value_exist 'mail' '$DKIM'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Generating dkim
rm -f $V_USERS/$user/mail/$domain.pem
rm -f $V_USERS/$user/mail/$domain.pub
rm -f $V_HOME/$user/conf/mail/$domain/dkim.pem
# Checking dns domain
check_dns_domain=$(is_domain_valid 'dns')
if [ "$?" -eq 0 ]; then
records=$($V_BIN/v_list_dns_domain_records $user $domain plain)
dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ')
for id in $dkim_records; do
$V_BIN/v_delete_dns_domain_record $user $domain $id
done
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding dkim in config
update_domain_value 'mail' '$DKIM' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_dkim $user $domain"
log_event 'system' "$V_EVENT"
exit