forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-sys-webmail
More file actions
executable file
·69 lines (52 loc) · 2.05 KB
/
v-change-sys-webmail
File metadata and controls
executable file
·69 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# info: change webmail alias url
# options: WEBMAIL
#
# This function changes the webmail url in apache2 or nginx configuration.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
WEBMAIL=$1
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
# Get existing system webmail alias
export $WEBMAIL_ALIAS
# Define aliases
OLD_ALIAS=$WEBMAIL_ALIAS
NEW_ALIAS=$1
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'WEBMAIL'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Delete old webmail configuration
for user in `ls /usr/local/hestia/data/users/`; do
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
$BIN/v-delete-webmail $user $domain
done
done
# Set new webmail alias
sed -i "s|WEBMAIL_ALIAS='$OLD_ALIAS'|WEBMAIL_ALIAS='$NEW_ALIAS'|gI" $HESTIA/conf/hestia.conf
for user in `ls /usr/local/hestia/data/users/`; do
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
echo "Changing webmail alias for $domain"
$BIN/v-add-webmail $user $domain
done
done
# Update alias (non-subdomain) configuration to match
sed -i "s|Alias \/webmail|Alias \/$NEW_ALIAS|gI" /etc/apache2/conf.d/roundcube.conf
sed -i "s|location \/webmail|location \/$NEW_ALIAS|gI" /etc/nginx/conf.d/webmail.inc
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Restart services
$BIN/v-restart-web $restart
$BIN/v-restart-proxy $restart
# Logging
log_history "changed system webmail alias to $NEW_ALIAS"
log_event "$OK" "$ARGUMENTS"
exit