Skip to content

Commit 94ad4e8

Browse files
Kristan Kenneyunknown
authored andcommitted
Add v-rebuild-mail-domain
Allows the user to rebuild a single mail domain
1 parent 4620390 commit 94ad4e8

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

bin/v-rebuild-mail-domain

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# info: rebuild mail domain
3+
# options: USER DOMAIN
4+
#
5+
# The function rebuilds configuration files for a single domain.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
user=$1
14+
domain=$2
15+
16+
# Includes
17+
source $HESTIA/func/main.sh
18+
source $HESTIA/func/domain.sh
19+
source $HESTIA/func/rebuild.sh
20+
source $HESTIA/conf/hestia.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'USER DOMAIN'
28+
is_format_valid 'user'
29+
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
30+
is_object_valid 'user' 'USER' "$user"
31+
is_object_unsuspended 'user' 'USER' "$user"
32+
is_object_valid 'mail' 'DOMAIN' "$domain"
33+
34+
if [ "$MAIL_SYSTEM" = 'remote' ]; then
35+
exit
36+
fi
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Rebuild mail domain configuration
44+
rebuild_mail_domain_conf
45+
46+
# Rebuild webmail configuration
47+
if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
48+
$BIN/v-delete-webmail $user $domain ''
49+
$BIN/v-add-webmail $user $domain ''
50+
fi
51+
52+
#----------------------------------------------------------#
53+
# Hestia #
54+
#----------------------------------------------------------#
55+
56+
# Updating counters
57+
update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS"
58+
update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM"
59+
update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS"
60+
update_user_value "$user" '$U_MAIL_SSL' "$U_MAIL_SSL"
61+
update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL"
62+
update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL"
63+
64+
# Logging
65+
log_event "$OK" "$ARGUMENTS"
66+
67+
exit

0 commit comments

Comments
 (0)