mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 13:01:52 -07:00
completed about 20% of email api
This commit is contained in:
parent
af54a85367
commit
8f6fbfc0e8
12 changed files with 668 additions and 59 deletions
|
@ -87,6 +87,7 @@ echo "$dns_rec" >> $zone
|
||||||
sort_dns_records
|
sort_dns_records
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
|
conf="$V_HOME/$user/conf/dns/$domain.db"
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: add mail domain
|
# info: add mail domain
|
||||||
# options: user domain [antispam] [antivirus]
|
# options: user domain [antispam] [antivirus] [dkim] [dkim_size]
|
||||||
#
|
#
|
||||||
# The function adds MAIL domain.
|
# The function adds MAIL domain.
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
antispam=${3-yes}
|
antispam=${3-yes}
|
||||||
antivirus=${3-yes}
|
antivirus=${4-yes}
|
||||||
|
dkim=${5-yes}
|
||||||
|
dkim_size=${6-512}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -29,10 +31,10 @@ source $V_FUNC/domain.func
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
# Checking arg number
|
||||||
check_args '2' "$#" 'user domain [antispam] [antivirus]'
|
check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'domain' 'antispam' 'antivirus'
|
format_validation 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
|
||||||
|
|
||||||
# Checking dns system is enabled
|
# Checking dns system is enabled
|
||||||
is_system_enabled 'MAIL_SYSTEM'
|
is_system_enabled 'MAIL_SYSTEM'
|
||||||
|
@ -50,56 +52,61 @@ is_domain_new 'mail'
|
||||||
is_package_full 'MAIL_DOMAINS'
|
is_package_full 'MAIL_DOMAINS'
|
||||||
|
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining variables
|
# Adding domain directory
|
||||||
i=1
|
mkdir $V_HOME/$user/conf/mail/$domain
|
||||||
ns=$(get_user_value '$NS')
|
touch $V_HOME/$user/conf/mail/$domain/aliases
|
||||||
for nameserver in ${ns//,/ };do
|
touch $V_HOME/$user/conf/mail/$domain/protection
|
||||||
eval ns$i=$nameserver
|
touch $V_HOME/$user/conf/mail/$domain/passwd
|
||||||
i=$((i + 1))
|
chown -R root:mail $V_HOME/$user/conf/mail/$domain
|
||||||
done
|
chmod 770 $V_HOME/$user/conf/mail/$domain
|
||||||
|
chmod 660 $V_HOME/$user/conf/mail/$domain*
|
||||||
|
|
||||||
if [ -z "$soa" ]; then
|
# Adding antispam protection
|
||||||
soa="$ns1"
|
if [ "$antispam" = 'yes' ]; then
|
||||||
|
echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding zone to dns dir
|
# Adding antivirus protection
|
||||||
cat $V_DNSTPL/$template.tpl |\
|
if [ "$antivirus" = 'yes' ]; then
|
||||||
sed -e "s/%ip%/$ip/g" \
|
echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
|
||||||
-e "s/%domain_idn%/$domain_idn/g" \
|
fi
|
||||||
-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
|
# Adding dkim
|
||||||
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
|
if [ "$dkim" = 'yes' ]; then
|
||||||
dns_rec="$dns_rec SOA='$soa' SUSPENDED='no' DATE='$V_DATE'"
|
openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null
|
||||||
echo "$dns_rec" >> $V_USERS/$user/dns.conf
|
openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \
|
||||||
chmod 660 $V_USERS/$user/dns.conf
|
-out $V_USERS/$user/mail/$domain.pub 2>/dev/null
|
||||||
|
chmod 660 $V_USERS/$user/mail/$domain.*
|
||||||
|
|
||||||
# Adding zone in named.conf
|
cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem
|
||||||
named="zone \"$domain_idn\" {type master; file"
|
chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem
|
||||||
named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};"
|
chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem
|
||||||
echo "$named" >> /etc/named.conf
|
|
||||||
|
|
||||||
# Updating domain dns zone
|
# Adding dkim dns records
|
||||||
conf="$V_HOME/$user/conf/dns/$domain.db"
|
check_dns_domain=$(is_domain_valid 'dns')
|
||||||
update_domain_zone
|
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"
|
||||||
|
|
||||||
chmod 640 $conf
|
record='mail._domainkey'
|
||||||
chown root:named $conf
|
selector="\"k=rsa\; p=$p\""
|
||||||
|
$V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
# Increasing domain value
|
||||||
increase_user_value "$user" '$U_DNS_DOMAINS'
|
increase_user_value "$user" '$U_MAIL_DOMAINS'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
|
||||||
restart_schedule 'dns'
|
|
||||||
|
|
||||||
# Logging
|
# 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"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
74
bin/v_add_mail_domain_antispam
Executable file
74
bin/v_add_mail_domain_antispam
Executable file
|
@ -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
bin/v_add_mail_domain_antivirus
Executable file
74
bin/v_add_mail_domain_antivirus
Executable file
|
@ -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
bin/v_add_mail_domain_cactchall
Executable file
76
bin/v_add_mail_domain_cactchall
Executable file
|
@ -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
bin/v_add_mail_domain_dkim
Executable file
96
bin/v_add_mail_domain_dkim
Executable file
|
@ -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
|
|
@ -65,15 +65,22 @@ ns2=$(get_user_value '$NS2')
|
||||||
|
|
||||||
# Changing tpl
|
# Changing tpl
|
||||||
update_domain_value 'dns' '$TPL' "$template"
|
update_domain_value 'dns' '$TPL' "$template"
|
||||||
|
|
||||||
cat $V_DNSTPL/$template.tpl |\
|
cat $V_DNSTPL/$template.tpl |\
|
||||||
sed -e "s/%ip%/$ip/g" \
|
sed -e "s/%ip%/$ip/g" \
|
||||||
-e "s/%domain_idn%/$domain_idn/g" \
|
-e "s/%domain_idn%/$domain_idn/g" \
|
||||||
-e "s/%domain%/$domain/g" \
|
-e "s/%domain%/$domain/g" \
|
||||||
-e "s/%ns1%/$ns1/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
|
# Updating zone
|
||||||
|
conf="$V_HOME/$user/conf/dns/$domain.db"
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
|
|
||||||
|
|
||||||
|
|
115
bin/v_list_mail_domain
Executable file
115
bin/v_list_mail_domain
Executable file
|
@ -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
bin/v_list_mail_domain_dkim
Executable file
80
bin/v_list_mail_domain_dkim
Executable file
|
@ -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
bin/v_list_mail_domains
Executable file
60
bin/v_list_mail_domains
Executable file
|
@ -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
|
|
@ -1,19 +1,19 @@
|
||||||
# Checking domain existance
|
# Checking domain existance
|
||||||
is_domain_new() {
|
is_domain_new() {
|
||||||
config_type="$1"
|
config_type="$1"
|
||||||
dom=${2-domain}
|
dom=${2-$domain}
|
||||||
check_all=$(grep -w $dom $V_USERS/*/*.conf)
|
check_all=$(grep -w $dom $V_USERS/*/*.conf)
|
||||||
if [ ! -z "$check_all" ]; then
|
if [ ! -z "$check_all" ]; then
|
||||||
check_ownership=$(grep -w $dom $V_USERS/$user/*.conf)
|
check_ownership=$(grep -w $dom $V_USERS/$user/*.conf)
|
||||||
if [ ! -z "$check_ownership" ]; then
|
if [ ! -z "$check_ownership" ]; then
|
||||||
check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf)
|
check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf)
|
||||||
if [ ! -z "$check_type" ]; then
|
if [ ! -z "$check_type" ]; then
|
||||||
echo "Error: $dom exist"
|
echo "Error: domain $dom exist"
|
||||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Error: $dom exist"
|
echo "Error: domain $dom exist"
|
||||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
|
@ -26,7 +26,7 @@ is_domain_valid() {
|
||||||
|
|
||||||
# Checking result
|
# Checking result
|
||||||
if [ -z "$check_domain" ]; then
|
if [ -z "$check_domain" ]; then
|
||||||
echo "Error: domain not exist"
|
echo "Error: domain $domain not exist"
|
||||||
log_event 'debug' "$E_NOTEXIST $V_EVENT"
|
log_event 'debug' "$E_NOTEXIST $V_EVENT"
|
||||||
exit $E_NOTEXIST
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
@ -111,7 +111,7 @@ update_domain_zone() {
|
||||||
|
|
||||||
# Converting utf records to ascii
|
# Converting utf records to ascii
|
||||||
RECORD=$(idn --quiet -a -t "$RECORD")
|
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
|
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
|
||||||
done < $V_USERS/$user/dns/$domain
|
done < $V_USERS/$user/dns/$domain
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ is_domain_key_empty() {
|
||||||
|
|
||||||
# Checkng key
|
# Checkng key
|
||||||
if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
|
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"
|
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -329,6 +329,26 @@ format_validation() {
|
||||||
fi
|
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
|
# Defining format_ext function
|
||||||
format_ext() {
|
format_ext() {
|
||||||
val="$1"
|
val="$1"
|
||||||
|
@ -375,14 +395,15 @@ format_validation() {
|
||||||
case $var in
|
case $var in
|
||||||
antispam) format_bool "$v" ;;
|
antispam) format_bool "$v" ;;
|
||||||
antivirus) format_bool "$v" ;;
|
antivirus) format_bool "$v" ;;
|
||||||
dom_alias) format_dom "$v" ;;
|
|
||||||
auth_pass) format_pwd "$v" ;;
|
auth_pass) format_pwd "$v" ;;
|
||||||
auth_user) format_usr "$v" ;;
|
auth_user) format_usr "$v" ;;
|
||||||
ssl) format_usr "$v" ;;
|
|
||||||
domain) format_dom "$v" ;;
|
|
||||||
database) format_db "$v" ;;
|
database) format_db "$v" ;;
|
||||||
day) format_mhd "$v" ;;
|
day) format_mhd "$v" ;;
|
||||||
db_user) format_dbu "$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" ;;
|
dvalue) format_dvl "$v" ;;
|
||||||
fname) format_usr "$v" ;;
|
fname) format_usr "$v" ;;
|
||||||
job) format_int "$v" ;;
|
job) format_int "$v" ;;
|
||||||
|
@ -415,6 +436,7 @@ format_validation() {
|
||||||
password) format_pwd "$v" ;;
|
password) format_pwd "$v" ;;
|
||||||
port) format_int "$v" ;;
|
port) format_int "$v" ;;
|
||||||
rtype) format_rcd "$v" ;;
|
rtype) format_rcd "$v" ;;
|
||||||
|
ssl) format_usr "$v" ;;
|
||||||
shell) format_sh "$v" ;;
|
shell) format_sh "$v" ;;
|
||||||
soa) format_dom "$v" ;;
|
soa) format_dom "$v" ;;
|
||||||
suspend_url) format_url "$v" ;;
|
suspend_url) format_url "$v" ;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue