Skip to content

Commit bff4530

Browse files
committed
Fix for bulk actions
1 parent bdc8111 commit bff4530

File tree

5 files changed

+237
-83
lines changed

5 files changed

+237
-83
lines changed

bin/v-add-domain

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,39 @@ if [ -z "$ip" ]; then
4747
fi
4848
fi
4949

50-
# Web domain
50+
# Working on web domain
5151
if [ ! -z "$WEB_SYSTEM" ]; then
5252
$BIN/v-add-web-domain $user $domain $ip 'no'
53-
return_code=$?
53+
check_result $? "can't add web domain" >/dev/null
5454
fi
5555

56-
# Proxy support
57-
if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
58-
extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
59-
extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
60-
extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
61-
$BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
56+
# Working on DNS domain
57+
if [ ! -z "$DNS_SYSTEM" ]; then
58+
$BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" 'no'
59+
check_result $? "can't add dns domain" >/dev/null
6260
fi
6361

64-
# DNS domain
65-
if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
66-
$BIN/v-add-dns-domain $user $domain $ip 'no'
67-
return_code=$?
68-
fi
69-
70-
# Mail domain
71-
if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
62+
# Working on mail domain
63+
if [ ! -z "$MAIL_SYSTEM" ]; then
7264
$BIN/v-add-mail-domain $user $domain
73-
return_code=$?
65+
check_result $? "can't add mail domain" >/dev/null
7466
fi
7567

76-
# Restart services
77-
if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
68+
# Restarting services
69+
if [ "$restart" != 'no' ]; then
7870
$BIN/v-restart-web
79-
$BIN/v-restart-proxy
71+
check_result $? "can't restart web" > /dev/null
72+
if [ ! -z "$PROXY_SYSTEM" ]; then
73+
$BIN/v-restart-proxy
74+
check_result $? "can't restart proxy" > /dev/null
75+
fi
8076
$BIN/v-restart-dns
77+
check_result $? "can't restart dns" > /dev/null
8178
fi
8279

8380

8481
#----------------------------------------------------------#
8582
# Vesta #
8683
#----------------------------------------------------------#
8784

88-
exit $return_code
85+
exit

bin/v-delete-domain

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ restart="${3-yes}"
1616

1717
# Includes
1818
source $VESTA/func/main.sh
19-
source $VESTA/func/ip.sh
2019
source $VESTA/conf/vesta.conf
2120

2221

@@ -34,51 +33,53 @@ is_object_unsuspended 'user' 'USER' "$user"
3433
# Action #
3534
#----------------------------------------------------------#
3635

37-
# Web domain
38-
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
39-
check_web=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
40-
if [ ! -z "$check_web" ]; then
36+
# Working on Web domain
37+
if [ ! -z "$WEB_SYSTEM" ]; then
38+
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
39+
if [ ! -z "$str" ]; then
40+
domain_found='yes'
4141
$BIN/v-delete-web-domain $user $domain 'no'
42-
if [ $? -ne 0 ]; then
43-
exit $E_RESTART
44-
fi
42+
check_result $? "can't suspend web" > /dev/null
4543
fi
4644
fi
4745

48-
# DNS domain
49-
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
50-
check_dns=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
51-
if [ ! -z "$check_dns" ]; then
46+
# Working on DNS domain
47+
if [ ! -z "$DNS_SYSTEM" ]; then
48+
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
49+
if [ ! -z "$str" ]; then
50+
domain_found='yes'
5251
$BIN/v-delete-dns-domain $user $domain 'no'
53-
if [ $? -ne 0 ]; then
54-
exit $E_RESTART
55-
fi
52+
check_result $? "can't suspend dns" > /dev/null
5653
fi
5754
fi
5855

59-
# Mail domain
60-
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
61-
check_mail=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
62-
if [ ! -z "$check_mail" ]; then
56+
# Working on Mail domain
57+
if [ ! -z "$MAIL_SYSTEM" ]; then
58+
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
59+
if [ ! -z "$str" ]; then
60+
domain_found='yes'
6361
$BIN/v-delete-mail-domain $user $domain
64-
if [ $? -ne 0 ]; then
65-
exit $E_RESTART
66-
fi
62+
check_result $? "can't suspend mail" > /dev/null
6763
fi
6864
fi
6965

70-
# Check domain status
71-
if [ -z "$check_web" ] && [ -z "$check_dns" ] && [ -z "$check_mail" ]; then
66+
# Checking domain search result
67+
if [ -z "$domain_found" ]; then
7268
echo "Error: domain $domain doesn't exist"
7369
log_event "$E_NOTEXIST" "$EVENT"
7470
exit $E_NOTEXIST
7571
fi
7672

77-
# Restart services
73+
# Restarting services
7874
if [ "$restart" != 'no' ]; then
7975
$BIN/v-restart-web
80-
$BIN/v-restart-proxy
76+
check_result $? "can't restart web" > /dev/null
77+
if [ ! -z "$PROXY_SYSTEM" ]; then
78+
$BIN/v-restart-proxy
79+
check_result $? "can't restart proxy" > /dev/null
80+
fi
8181
$BIN/v-restart-dns
82+
check_result $? "can't restart dns" > /dev/null
8283
fi
8384

8485

bin/v-suspend-domain

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# info: suspend web/dns/mail domain
3+
# options: USER DOMAIN
4+
#
5+
# The function suspends web/dns/mail domain.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$2
15+
restart="${3-yes}"
16+
17+
# Includes
18+
source $VESTA/func/main.sh
19+
source $VESTA/conf/vesta.conf
20+
21+
22+
#----------------------------------------------------------#
23+
# Verifications #
24+
#----------------------------------------------------------#
25+
26+
check_args '2' "$#" 'USER DOMAIN'
27+
validate_format 'user' 'domain'
28+
is_object_valid 'user' 'USER' "$user"
29+
is_object_unsuspended 'user' 'USER' "$user"
30+
31+
32+
#----------------------------------------------------------#
33+
# Action #
34+
#----------------------------------------------------------#
35+
36+
# Working on Web domain
37+
if [ ! -z "$WEB_SYSTEM" ]; then
38+
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
39+
if [ ! -z "$str" ]; then
40+
domain_found='yes'
41+
$BIN/v-suspend-web-domain $user $domain 'no'
42+
check_result $? "can't suspend web" > /dev/null
43+
fi
44+
fi
45+
46+
# Working on DNS domain
47+
if [ ! -z "$DNS_SYSTEM" ]; then
48+
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
49+
if [ ! -z "$str" ]; then
50+
domain_found='yes'
51+
$BIN/v-suspend-dns-domain $user $domain 'no'
52+
check_result $? "can't suspend dns" > /dev/null
53+
fi
54+
fi
55+
56+
# Working on Mail domain
57+
if [ ! -z "$MAIL_SYSTEM" ]; then
58+
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
59+
if [ ! -z "$str" ]; then
60+
domain_found='yes'
61+
$BIN/v-suspend-mail-domain $user $domain
62+
check_result $? "can't suspend mail" > /dev/null
63+
fi
64+
fi
65+
66+
# Checking domain search result
67+
if [ -z "$domain_found" ]; then
68+
echo "Error: domain $domain doesn't exist"
69+
log_event "$E_NOTEXIST" "$EVENT"
70+
exit $E_NOTEXIST
71+
fi
72+
73+
# Restarting services
74+
if [ "$restart" != 'no' ]; then
75+
$BIN/v-restart-web
76+
check_result $? "can't restart web" > /dev/null
77+
if [ ! -z "$PROXY_SYSTEM" ]; then
78+
$BIN/v-restart-proxy
79+
check_result $? "can't restart proxy" > /dev/null
80+
fi
81+
$BIN/v-restart-dns
82+
check_result $? "can't restart dns" > /dev/null
83+
fi
84+
85+
86+
#----------------------------------------------------------#
87+
# Vesta #
88+
#----------------------------------------------------------#
89+
90+
exit

bin/v-unsuspend-domain

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
# info: unsuspend web/dns/mail domain
3+
# options: USER DOMAIN
4+
#
5+
# The function unsuspends web/dns/mail domain.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$2
15+
restart="${3-yes}"
16+
17+
# Includes
18+
source $VESTA/func/main.sh
19+
source $VESTA/conf/vesta.conf
20+
21+
22+
#----------------------------------------------------------#
23+
# Verifications #
24+
#----------------------------------------------------------#
25+
26+
check_args '2' "$#" 'USER DOMAIN'
27+
validate_format 'user' 'domain'
28+
is_object_valid 'user' 'USER' "$user"
29+
30+
31+
#----------------------------------------------------------#
32+
# Action #
33+
#----------------------------------------------------------#
34+
35+
# Working on Web domain
36+
if [ ! -z "$WEB_SYSTEM" ]; then
37+
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='yes")
38+
if [ ! -z "$str" ]; then
39+
domain_found='yes'
40+
$BIN/v-unsuspend-web-domain $user $domain 'no'
41+
check_result $? "can't suspend web" > /dev/null
42+
fi
43+
fi
44+
45+
# Working on DNS domain
46+
if [ ! -z "$DNS_SYSTEM" ]; then
47+
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='yes")
48+
if [ ! -z "$str" ]; then
49+
domain_found='yes'
50+
$BIN/v-unsuspend-dns-domain $user $domain 'no'
51+
check_result $? "can't suspend dns" > /dev/null
52+
fi
53+
fi
54+
55+
# Working on Mail domain
56+
if [ ! -z "$MAIL_SYSTEM" ]; then
57+
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='yes")
58+
if [ ! -z "$str" ]; then
59+
domain_found='yes'
60+
$BIN/v-unsuspend-mail-domain $user $domain
61+
check_result $? "can't suspend mail" > /dev/null
62+
fi
63+
fi
64+
65+
# Checking domain search result
66+
if [ -z "$domain_found" ]; then
67+
echo "Error: domain $domain doesn't exist"
68+
log_event "$E_NOTEXIST" "$EVENT"
69+
exit $E_NOTEXIST
70+
fi
71+
72+
# Restarting services
73+
if [ "$restart" != 'no' ]; then
74+
$BIN/v-restart-web
75+
check_result $? "can't restart web" > /dev/null
76+
if [ ! -z "$PROXY_SYSTEM" ]; then
77+
$BIN/v-restart-proxy
78+
check_result $? "can't restart proxy" > /dev/null
79+
fi
80+
$BIN/v-restart-dns
81+
check_result $? "can't restart dns" > /dev/null
82+
fi
83+
84+
85+
#----------------------------------------------------------#
86+
# Vesta #
87+
#----------------------------------------------------------#
88+
89+
exit

0 commit comments

Comments
 (0)