Skip to content

Commit b05944f

Browse files
committed
mail api 40% completed
1 parent 9e0bc28 commit b05944f

7 files changed

+245
-12
lines changed

bin/v_add_mail_domain

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ chown -R root:mail $V_HOME/$user/conf/mail/$domain
6565
chmod 770 $V_HOME/$user/conf/mail/$domain
6666
chmod 660 $V_HOME/$user/conf/mail/$domain*
6767

68+
# Adding symlink
69+
ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/
70+
6871
# Adding antispam protection
6972
if [ "$antispam" = 'yes' ]; then
7073
echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection

bin/v_add_mail_domain_antivirus

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# info: add mail domain antivirus support
33
# options: user domain
44
#
5-
# The function enables clamav for incomming emails.
5+
# The function enables clamav scan for incomming emails.
66

77

88
#----------------------------------------------------------#
@@ -47,15 +47,15 @@ is_domain_valid 'mail'
4747
# Checking domain is not suspened
4848
is_domain_suspended 'mail'
4949

50-
# Checking errorlog is not added
50+
# Checking current value
5151
is_domain_key_empty 'mail' '$ANTIVIRUS'
5252

5353

5454
#----------------------------------------------------------#
5555
# Action #
5656
#----------------------------------------------------------#
5757

58-
# Adding antispam key to config
58+
# Adding antivirus key to config
5959
if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
6060
echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
6161
fi
@@ -64,7 +64,7 @@ fi
6464
# Vesta #
6565
#----------------------------------------------------------#
6666

67-
# Adding antispam in config
67+
# Adding antivirus in config
6868
update_domain_value 'mail' '$ANTIVIRUS' 'yes'
6969

7070
# Logging

bin/v_add_mail_domain_cactchall

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ check_args '3' "$#" 'user domain email'
3232

3333
# Checking argument format
3434
format_validation 'user' 'domain' 'email'
35-
exit
3635

3736
# Checking dns system is enabled
3837
is_system_enabled 'MAIL_SYSTEM'
@@ -50,27 +49,27 @@ is_domain_valid 'mail'
5049
is_domain_suspended 'mail'
5150

5251
# Checking errorlog is not added
53-
is_domain_key_empty 'mail' '$ANTIVIRUS'
52+
is_domain_key_empty 'mail' '$CATCHALL'
5453

5554

5655
#----------------------------------------------------------#
5756
# Action #
5857
#----------------------------------------------------------#
5958

60-
# Adding antispam key to config
61-
if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
62-
echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
63-
fi
59+
# Adding catchall alias
60+
sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
61+
echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
62+
6463

6564
#----------------------------------------------------------#
6665
# Vesta #
6766
#----------------------------------------------------------#
6867

6968
# Adding antispam in config
70-
update_domain_value 'mail' '$ANTIVIRUS' 'yes'
69+
update_domain_value 'mail' '$CATCHALL' "$email"
7170

7271
# Logging
73-
log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain"
72+
log_history "$V_EVENT" "v_delete_mail_domain_catchall $user $domain"
7473
log_event 'system' "$V_EVENT"
7574

7675
exit

bin/v_delete_dns_domain_record

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fi
6363
sort_dns_records
6464

6565
# Updating zone
66+
conf="$V_HOME/$user/conf/dns/$domain.db"
6667
update_domain_zone
6768

6869

bin/v_delete_mail_domain_antispam

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# info: delete mail domain antispam support
3+
# options: user domain
4+
#
5+
# The function disable spamassasin for incomming emails.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
16+
domain_idn=$(idn -t --quiet -a "$domain")
17+
18+
# Importing variables
19+
source $VESTA/conf/vars.conf
20+
source $V_CONF/vesta.conf
21+
source $V_FUNC/shared.func
22+
source $V_FUNC/domain.func
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
# Checking arg number
30+
check_args '2' "$#" 'user domain'
31+
32+
# Checking argument format
33+
format_validation 'user' 'domain'
34+
35+
# Checking dns system is enabled
36+
is_system_enabled 'MAIL_SYSTEM'
37+
38+
# Checking user
39+
is_user_valid
40+
41+
# Checking user is active
42+
is_user_suspended
43+
44+
# Checking domain
45+
is_domain_valid 'mail'
46+
47+
# Checking domain is not suspened
48+
is_domain_suspended 'mail'
49+
50+
# Checking current value
51+
is_domain_value_exist 'mail' '$ANTISPAM'
52+
53+
54+
#----------------------------------------------------------#
55+
# Action #
56+
#----------------------------------------------------------#
57+
58+
# Delete antispam key
59+
sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection
60+
61+
62+
#----------------------------------------------------------#
63+
# Vesta #
64+
#----------------------------------------------------------#
65+
66+
# Delete antispam in config
67+
update_domain_value 'mail' '$ANTISPAM' 'no'
68+
69+
# Logging
70+
log_history "$V_EVENT" "v_add_mail_domain_antispam $user $domain"
71+
log_event 'system' "$V_EVENT"
72+
73+
exit

bin/v_delete_mail_domain_antivirus

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# info: delete mail domain antivirus support
3+
# options: user domain
4+
#
5+
# The function disables clamav scan for incomming emails.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
16+
domain_idn=$(idn -t --quiet -a "$domain")
17+
18+
# Importing variables
19+
source $VESTA/conf/vars.conf
20+
source $V_CONF/vesta.conf
21+
source $V_FUNC/shared.func
22+
source $V_FUNC/domain.func
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
# Checking arg number
30+
check_args '2' "$#" 'user domain'
31+
32+
# Checking argument format
33+
format_validation 'user' 'domain'
34+
35+
# Checking dns system is enabled
36+
is_system_enabled 'MAIL_SYSTEM'
37+
38+
# Checking user
39+
is_user_valid
40+
41+
# Checking user is active
42+
is_user_suspended
43+
44+
# Checking domain
45+
is_domain_valid 'mail'
46+
47+
# Checking domain is not suspened
48+
is_domain_suspended 'mail'
49+
50+
# Checking current value
51+
is_domain_value_exist 'mail' '$ANTIVIRUS'
52+
53+
54+
#----------------------------------------------------------#
55+
# Action #
56+
#----------------------------------------------------------#
57+
58+
# Delete antivirus key
59+
sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection
60+
61+
62+
#----------------------------------------------------------#
63+
# Vesta #
64+
#----------------------------------------------------------#
65+
66+
# Delete antivirus in config
67+
update_domain_value 'mail' '$ANTIVIRUS' 'no'
68+
69+
# Logging
70+
log_history "$V_EVENT" "v_add_mail_domain_antivirus $user $domain"
71+
log_event 'system' "$V_EVENT"
72+
73+
exit

bin/v_delete_mail_domain_dkim

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
# info: delete mail domain dkim support
3+
# options: user domain [dkim_size]
4+
#
5+
# The function delete DKIM domain pem.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
16+
17+
# Importing variables
18+
source $VESTA/conf/vars.conf
19+
source $V_CONF/vesta.conf
20+
source $V_FUNC/shared.func
21+
source $V_FUNC/domain.func
22+
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
# Checking arg number
29+
check_args '2' "$#" 'user domain'
30+
31+
# Checking argument format
32+
format_validation 'user' 'domain'
33+
34+
# Checking dns system is enabled
35+
is_system_enabled 'MAIL_SYSTEM'
36+
37+
# Checking user
38+
is_user_valid
39+
40+
# Checking user is active
41+
is_user_suspended
42+
43+
# Checking domain
44+
is_domain_valid 'mail'
45+
46+
# Checking domain is not suspened
47+
is_domain_suspended 'mail'
48+
49+
# Checking errorlog is not added
50+
is_domain_value_exist 'mail' '$DKIM'
51+
52+
53+
#----------------------------------------------------------#
54+
# Action #
55+
#----------------------------------------------------------#
56+
57+
# Generating dkim
58+
rm -f $V_USERS/$user/mail/$domain.pem
59+
rm -f $V_USERS/$user/mail/$domain.pub
60+
rm -f $V_HOME/$user/conf/mail/$domain/dkim.pem
61+
62+
# Checking dns domain
63+
check_dns_domain=$(is_domain_valid 'dns')
64+
if [ "$?" -eq 0 ]; then
65+
records=$($V_BIN/v_list_dns_domain_records $user $domain plain)
66+
dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ')
67+
for id in $dkim_records; do
68+
$V_BIN/v_delete_dns_domain_record $user $domain $id
69+
done
70+
fi
71+
72+
73+
#----------------------------------------------------------#
74+
# Vesta #
75+
#----------------------------------------------------------#
76+
77+
# Adding dkim in config
78+
update_domain_value 'mail' '$DKIM' 'no'
79+
80+
# Logging
81+
log_history "$V_EVENT" "v_add_mail_domain_dkim $user $domain"
82+
log_event 'system' "$V_EVENT"
83+
84+
exit

0 commit comments

Comments
 (0)