Skip to content

Commit 03237bf

Browse files
committed
added user&web bulk operation support
1 parent 15cc5a1 commit 03237bf

21 files changed

+287
-57
lines changed

bin/v_delete_mail_domains

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# info: delete mail domains
3+
# options: user
4+
#
5+
# The function for deleting all users mail domains.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
15+
# Includes
16+
source $VESTA/conf/vesta.conf
17+
source $VESTA/func/main.sh
18+
19+
20+
#----------------------------------------------------------#
21+
# Verifications #
22+
#----------------------------------------------------------#
23+
24+
check_args '1' "$#" 'user'
25+
validate_format 'user'
26+
is_system_enabled "$MAIL_SYSTEM"
27+
is_object_valid 'user' 'USER' "$user"
28+
29+
30+
#----------------------------------------------------------#
31+
# Action #
32+
#----------------------------------------------------------#
33+
34+
# Starting delete loop
35+
for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do
36+
$BIN/v_delete_mail_domain "$user" "$domain"
37+
done
38+
39+
40+
#----------------------------------------------------------#
41+
# Vesta #
42+
#----------------------------------------------------------#
43+
44+
# Logging
45+
log_event "$OK" "$EVENT"
46+
47+
exit

bin/v_delete_user

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# Argument defenition
1414
user=$1
15+
restart=$2
1516

1617
# Includes
1718
source $VESTA/conf/vesta.conf
@@ -39,8 +40,8 @@ fi
3940

4041
# Checking web system is enabled
4142
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
42-
$BIN/v_unsuspend_web_domains $user
43-
$BIN/v_delete_web_domains $user
43+
$BIN/v_unsuspend_web_domains $user $restart
44+
$BIN/v_delete_web_domains $user $restart
4445
rv="$?"
4546
if [ "$rv" -ne '0' ]; then
4647
exit $rv
@@ -49,8 +50,8 @@ fi
4950

5051
# Checking dns system is enabled
5152
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
52-
$BIN/v_unsuspend_dns_domains $user
53-
$BIN/v_delete_dns_domains $user
53+
$BIN/v_unsuspend_dns_domains $user $restart
54+
$BIN/v_delete_dns_domains $user $restart
5455
rv="$?"
5556
if [ "$rv" -ne '0' ]; then
5657
exit $rv
@@ -60,7 +61,7 @@ fi
6061
# Checking mail system is enabled
6162
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
6263
$BIN/v_unsuspend_mail_domains $user
63-
#$BIN/v_delete_mail_domains $user
64+
$BIN/v_delete_mail_domains $user
6465
rv="$?"
6566
if [ "$rv" -ne '0' ]; then
6667
exit $rv

bin/v_delete_web_domains

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: delete web domains
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function deteles all user's webdomains.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -21,7 +22,7 @@ source $VESTA/func/main.sh
2122
# Verifications #
2223
#----------------------------------------------------------#
2324

24-
check_args '1' "$#" 'user'
25+
check_args '1' "$#" 'user [restart]'
2526
validate_format 'user'
2627
is_system_enabled "$WEB_SYSTEM"
2728
is_object_valid 'user' 'USER' "$user"
@@ -41,6 +42,11 @@ done
4142
# Vesta #
4243
#----------------------------------------------------------#
4344

45+
# Restart web server
46+
if [ "$restart" != 'no' ]; then
47+
$BIN/v_restart_web "$EVENT"
48+
fi
49+
4450
# Logging
4551
log_event "$OK" "$EVENT"
4652

bin/v_rebuild_cron_jobs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: rebuild cron jobs
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function rebuilds system cron config file for specified user.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -21,7 +22,7 @@ source $VESTA/func/main.sh
2122
# Verifications #
2223
#----------------------------------------------------------#
2324

24-
check_args '1' "$#" 'user'
25+
check_args '1' "$#" 'user [restart]'
2526
validate_format 'user'
2627
is_system_enabled "$CRON_SYSTEM"
2728
is_object_valid 'user' 'USER' "$user"
@@ -40,7 +41,9 @@ sync_cron_jobs
4041
#----------------------------------------------------------#
4142

4243
# Restart crond
43-
$BIN/v_restart_cron "$EVENT"
44+
if [ "$restart" != 'no' ]; then
45+
$BIN/v_restart_cron "$EVENT"
46+
fi
4447

4548
# Logging
4649
log_event "$OK" "$EVENT"

bin/v_rebuild_dns_domains

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: rebuild dns domains
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function rebuilds BIND configuration files for all dns domains.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -22,7 +23,7 @@ source $VESTA/func/domain.sh
2223
# Verifications #
2324
#----------------------------------------------------------#
2425

25-
check_args '1' "$#" 'user'
26+
check_args '1' "$#" 'user [restart]'
2627
validate_format 'user'
2728
is_system_enabled "$DNS_SYSTEM"
2829
is_object_valid 'user' 'USER' "$user"
@@ -117,7 +118,9 @@ update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
117118
update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
118119

119120
# Restart named
120-
$BIN/v_restart_dns "$EVENT"
121+
if [ "$restart" != 'no' ]; then
122+
$BIN/v_restart_dns "$EVENT"
123+
fi
121124

122125
# Logging
123126
log_event "$OK" "$EVENT"

bin/v_rebuild_user

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: rebuild system user
3-
# options: user [full]
3+
# options: user [restart]
44
#
55
# The function rebuilds system user account.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -21,7 +22,7 @@ source $VESTA/func/main.sh
2122
# Verifications #
2223
#----------------------------------------------------------#
2324

24-
check_args '1' "$#" 'user'
25+
check_args '1' "$#" 'user [restart]'
2526
validate_format 'user'
2627
is_object_valid 'user' 'USER' "$user"
2728
is_object_unsuspended 'user' 'USER' "$user"
@@ -69,13 +70,13 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
6970
chmod 751 $HOMEDIR/$user/web
7071
chmod 777 $HOMEDIR/$user/tmp
7172
chown $user:$user $HOMEDIR/$user/web
72-
$BIN/v_rebuild_web_domains $user
73+
$BIN/v_rebuild_web_domains $user $restart
7374
fi
7475

7576
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
7677
mkdir -p $HOMEDIR/$user/conf/dns
7778
chmod 751 $HOMEDIR/$user/conf/dns
78-
$BIN/v_rebuild_dns_domains $user
79+
$BIN/v_rebuild_dns_domains $user $restart
7980
fi
8081

8182
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
@@ -92,7 +93,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
9293
fi
9394

9495
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
95-
$BIN/v_rebuild_cron_jobs $user
96+
$BIN/v_rebuild_cron_jobs $user $restart
9697
fi
9798

9899

bin/v_rebuild_web_domains

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: rebuild dns domains
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function rebuilds BIND configuration files for all dns domains.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -23,7 +24,7 @@ source $VESTA/func/ip.sh
2324
# Verifications #
2425
#----------------------------------------------------------#
2526

26-
check_args '1' "$#" 'user'
27+
check_args '1' "$#" 'user [restart]'
2728
validate_format 'user'
2829
is_system_enabled "$WEB_SYSTEM"
2930
is_object_valid 'user' 'USER' "$user"
@@ -271,7 +272,9 @@ update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
271272
update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
272273

273274
# Restart web server
274-
$BIN/v_restart_web "$EVENT"
275+
if [ "$restart" != 'no' ]; then
276+
$BIN/v_restart_web "$EVENT"
277+
fi
275278

276279
# Logging
277280
log_event "$OK" "$EVENT"

bin/v_suspend_cron_jobs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: Suspending sys cron jobs
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function suspends all user cron jobs.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -41,7 +42,9 @@ done
4142
#----------------------------------------------------------#
4243

4344
# Restart crond
44-
$BIN/v_restart_cron "$EVENT"
45+
if [ "$restart" != 'no' ]; then
46+
$BIN/v_restart_cron "$EVENT"
47+
fi
4548

4649
# Logging
4750
log_event "$OK" "$EVENT"

bin/v_suspend_dns_domains

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: suspend dns domains
3-
# options: user
3+
# options: user [restart]
44
#
55
# The function suspends all user's DNS domains.
66

@@ -11,6 +11,7 @@
1111

1212
# Argument defenition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $VESTA/conf/vesta.conf
@@ -21,7 +22,7 @@ source $VESTA/func/main.sh
2122
# Verifications #
2223
#----------------------------------------------------------#
2324

24-
check_args '1' "$#" 'user'
25+
check_args '1' "$#" 'user [restart]'
2526
validate_format 'user'
2627
is_system_enabled "$DNS_SYSTEM"
2728
is_object_valid 'user' 'USER' "$user"
@@ -41,8 +42,10 @@ done
4142
# Vesta #
4243
#----------------------------------------------------------#
4344

44-
# Adding task to the vesta pipe
45-
$BIN/v_restart_dns "$EVENT"
45+
# Restart dns server
46+
if [ "$restart" != 'no' ]; then
47+
$BIN/v_restart_dns "$EVENT"
48+
fi
4649

4750
# Logging
4851
log_event "$OK" "$EVENT"

bin/v_suspend_mail_domain

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ rm -f /etc/exim/domains/$domain
4949
# Updating config
5050
update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
5151
sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf
52+
increase_user_value "$user" '$SUSPENDED_MAIL'
53+
5254

5355
# Logging
5456
log_event "$OK" "$EVENT"

0 commit comments

Comments
 (0)