Skip to content

Commit 9cce9eb

Browse files
author
Kristan Kenney
committed
Merge branch 'bugfix-webmail-alias' into develop
2 parents d8584c5 + 9308979 commit 9cce9eb

34 files changed

+77
-87
lines changed

bin/v-change-sys-webmail

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,54 @@ WEBMAIL=$1
1616
source $HESTIA/func/main.sh
1717
source $HESTIA/conf/hestia.conf
1818

19+
# Get existing system webmail alias
20+
export $WEBMAIL_ALIAS
21+
22+
# Define aliases
23+
OLD_ALIAS=$WEBMAIL_ALIAS
24+
NEW_ALIAS=$1
1925

2026
#----------------------------------------------------------#
2127
# Verifications #
2228
#----------------------------------------------------------#
2329

2430
check_args '1' "$#" 'WEBMAIL'
2531

26-
# Check if string has leading /
27-
if [[ ! ${WEBMAIL:0:1} == "/" ]]; then
28-
WEBMAIL="/$WEBMAIL"
29-
fi
30-
3132
#----------------------------------------------------------#
3233
# Action #
3334
#----------------------------------------------------------#
3435

35-
# Get existing apache2 webmail alias
36-
if [ -f /etc/apache2/conf.d/roundcube.conf ]; then
37-
apache_webmail=$(tail -n+3 /etc/apache2/conf.d/roundcube.conf | grep "Alias" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
38-
fi
39-
40-
# Get existing nginx webmail alias
41-
if [ -f /etc/nginx/conf.d/webmail.inc ]; then
42-
nginx_webmail=$(cat /etc/nginx/conf.d/webmail.inc | grep "location" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
43-
fi
44-
45-
# Check if alias is different for apache2
46-
if [ ! -z "$apache_webmail" ]; then
47-
if [ ! "$apache_webmail" = "$WEBMAIL" ]; then
48-
# Replace webmail alias in config files.
49-
sed -i "s|Alias $apache_webmail|Alias $WEBMAIL|" /etc/apache2/conf.d/roundcube.conf
36+
# Delete old webmail configuration
37+
for user in `ls /usr/local/hestia/data/users/`; do
38+
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
39+
$BIN/v-delete-webmail $user $domain
40+
done
41+
done
5042

51-
# Replace in Backend UI
52-
sed -i "s|$apache_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/admin/list_mail.html
53-
sed -i "s|$apache_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/user/list_mail.html
43+
# Set new webmail alias
44+
sed -i "s|WEBMAIL_ALIAS='$OLD_ALIAS'|WEBMAIL_ALIAS='$NEW_ALIAS'|gI" $HESTIA/conf/hestia.conf
5445

55-
# Restart services
56-
$HESTIA/bin/v-restart-service apache2
57-
fi
58-
fi
59-
60-
# Check if alias is different for nginx
61-
if [ ! -z "$nginx_webmail" ]; then
62-
if [ ! "$nginx_webmail" = "$WEBMAIL" ]; then
63-
# Replace webmail alias in config files.
64-
sed -i "s|$nginx_webmail|$WEBMAIL|" /etc/nginx/conf.d/webmail.inc
65-
sed -i "s|/var/lib$WEBMAIL|/var/lib/roundcube|" /etc/nginx/conf.d/webmail.inc
66-
67-
# Replace in Backend UI
68-
sed -i "s|$nginx_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/admin/list_mail.html
69-
sed -i "s|$nginx_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/user/list_mail.html
70-
71-
# Restart services
72-
$HESTIA/bin/v-restart-service nginx
73-
fi
74-
fi
46+
for user in `ls /usr/local/hestia/data/users/`; do
47+
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
48+
echo "Changing webmail alias for $domain"
49+
$BIN/v-add-webmail $user $domain
50+
done
51+
done
7552

53+
# Update alias (non-subdomain) configuration to match
54+
sed -i "s|Alias \/webmail|Alias \/$NEW_ALIAS|gI" /etc/apache2/conf.d/roundcube.conf
55+
sed -i "s|location \/webmail|location \/$NEW_ALIAS|gI" /etc/nginx/conf.d/webmail.inc
7656

7757
#----------------------------------------------------------#
7858
# Hestia #
7959
#----------------------------------------------------------#
8060

61+
# Restart services
62+
$BIN/v-restart-web $restart
63+
$BIN/v-restart-proxy $restart
64+
8165
# Logging
82-
#log_event "$OK" "$ARGUMENTS"
66+
log_history "changed system webmail alias to $NEW_ALIAS"
67+
log_event "$OK" "$ARGUMENTS"
8368

8469
exit

bin/v-list-sys-config

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ json_list() {
4646
"LANGUAGE": "'$LANGUAGE'",
4747
"BACKUP_GZIP": "'$BACKUP_GZIP'",
4848
"BACKUP": "'$BACKUP'",
49-
"MAIL_URL": "'$MAIL_URL'",
49+
"WEBMAIL_ALIAS": "'$WEBMAIL_ALIAS'",
5050
"DB_PMA_URL": "'$DB_PMA_URL'",
5151
"DB_PGA_URL": "'$DB_PGA_URL'",
5252
"SOFTACULOUS": "'$SOFTACULOUS'"
@@ -85,8 +85,9 @@ shell_list() {
8585
echo -n " + $ANTISPAM_SYSTEM"
8686
fi
8787
echo
88-
if [ ! -z "$MAIL_URL" ]; then
89-
echo "Web Mail: hostname + $MAIL_URL"
88+
if [ ! -z "$WEBMAIL_ALIAS" ]; then
89+
echo "Webmail (subdomain): $WEBMAIL_ALIAS.domain.tld"
90+
echo "Webmail (alias): hostname/$WEBMAIL_ALIAS"
9091
fi
9192
fi
9293
if [ ! -z "$DB_SYSTEM" ]; then
@@ -139,7 +140,7 @@ plain_list() {
139140
echo -ne "$DNS_SYSTEM\t$DNS_CLUSTER\t$STATS_SYSTEM\t$BACKUP_SYSTEM\t"
140141
echo -ne "$CRON_SYSTEM\t$DISK_QUOTA\t$FIREWALL_SYSTEM\t"
141142
echo -ne "$FIREWALL_EXTENSION\t$REPOSITORY\t$VERSION\t$LANGUAGE\t"
142-
echo -e "$BACKUP_GZIP\t$BACKUP\t$MAIL_URL\t$DB_PMA_URL\t$DB_PGA_URL"
143+
echo -e "$BACKUP_GZIP\t$BACKUP\t$WEBMAIL_ALIAS\t$DB_PMA_URL\t$DB_PGA_URL"
143144
}
144145

145146

@@ -152,7 +153,7 @@ csv_list() {
152153
echo -n "'DNS_SYSTEM','DNS_CLUSTER','STATS_SYSTEM','BACKUP_SYSTEM',"
153154
echo -n "'CRON_SYSTEM','DISK_QUOTA','FIREWALL_SYSTEM',"
154155
echo -n "'FIREWALL_EXTENSION','REPOSITORY',"
155-
echo -n "'VERSION','LANGUAGE','BACKUP_GZIP','BACKUP','MAIL_URL',"
156+
echo -n "'VERSION','LANGUAGE','BACKUP_GZIP','BACKUP','WEBMAIL_ALIAS',"
156157
echo -n "'DB_PMA_URL','DB_PGA_URL'"
157158
echo
158159
echo -n "'$WEB_SYSTEM','$WEB_RGROUPS','$WEB_PORT','$WEB_SSL',"
@@ -162,7 +163,7 @@ csv_list() {
162163
echo -n "'$DNS_SYSTEM','$DNS_CLUSTER','$STATS_SYSTEM','$BACKUP_SYSTEM',"
163164
echo -n "'$CRON_SYSTEM','$DISK_QUOTA','$FIREWALL_SYSTEM','$REPOSITORY',"
164165
echo -n "'$FIREWALL_EXTENSION','$VERSION','$LANGUAGE','$BACKUP_GZIP',"
165-
echo -n "'$BACKUP','$MAIL_URL','$DB_PMA_URL','$DB_PGA_URL'"
166+
echo -n "'$BACKUP','$WEBMAIL_ALIAS','$DB_PMA_URL','$DB_PGA_URL'"
166167
echo
167168
}
168169

install/upgrade/0.10.0-190430.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ HESTIA="/usr/local/hestia"
55
HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
66
hestiacp="$HESTIA/install/deb"
77

8-
# Add webmail alias variable to system configuration
9-
sed -i "/WEBMAIL_ALIAS/d" $HESTIA/conf/hestia.conf
10-
echo "WEBMAIL_ALIAS='webmail'" >> $HESTIA/conf/hestia.conf
8+
# Add webmail alias variable to system configuration if non-existent
9+
webmail_alias_check=$(cat $HESTIA/conf/hestia.conf | grep WEBMAIL_ALIAS)
10+
if [ -z "$WEBMAIL_ALIAS_CHECK" ]; then
11+
echo "(*) Adding global webmail alias to system configuration..."
12+
sed -i "/WEBMAIL_ALIAS/d" $HESTIA/conf/hestia.conf
13+
echo "WEBMAIL_ALIAS='webmail'" >> $HESTIA/conf/hestia.conf
14+
fi
1115

1216
# load hestia.conf
1317
source $HESTIA/conf/hestia.conf

web/add/mail/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
if (empty($_SESSION['error_msg'])) {
172172
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
173173
$webmail = "http://".$http_host."/webmail/";
174-
if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL'];
174+
if (!empty($_SESSION['WEBMAIL_ALIAS'])) $webmail = $_SESSION['WEBMAIL_ALIAS'];
175175
}
176176

177177
// Email login credentials

web/edit/server/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195

196196
// Update webmail url
197197
if (empty($_SESSION['error_msg'])) {
198-
if ($_POST['v_mail_url'] != $_SESSION['MAIL_URL']) {
199-
exec (HESTIA_CMD."v-change-sys-config-value MAIL_URL ".escapeshellarg($_POST['v_mail_url']), $output, $return_var);
198+
if ($_POST['v_webmail_alias'] != $_SESSION['WEBMAIL_ALIAS']) {
199+
exec (HESTIA_CMD."v-change-sys-webmail ".escapeshellarg($_POST['v_webmail_alias']), $output, $return_var);
200200
check_return_code($return_var,$output);
201201
unset($output);
202202
$v_mail_adv = 'yes';

web/inc/i18n/bs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@
559559
'MAIL Server' => 'MAIL Server',
560560
'Antivirus' => 'Antivirus',
561561
'AntiSpam' => 'AntiSpam',
562-
'Webmail URL' => 'Webmail URL',
562+
'Webmail URL' => 'Webmail Alias',
563563
'MySQL Support' => 'MySQL Support',
564564
'phpMyAdmin URL' => 'phpMyAdmin URL',
565565
'PostgreSQL Support' => 'PostgreSQL Support',

web/inc/i18n/cz.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
'MAIL Server' => 'MAIL Server',
561561
'Antivirus' => 'Antivirus',
562562
'AntiSpam' => 'AntiSpam',
563-
'Webmail URL' => 'Webmail URL',
563+
'Webmail URL' => 'Webmail Alias',
564564
'MySQL Support' => 'MySQL Support',
565565
'phpMyAdmin URL' => 'phpMyAdmin URL',
566566
'PostgreSQL Support' => 'PostgreSQL Support',

web/inc/i18n/da.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
'MAIL Server' => 'MAIL Server',
562562
'Antivirus' => 'Antivirus',
563563
'AntiSpam' => 'AntiSpam',
564-
'Webmail URL' => 'Webmail URL',
564+
'Webmail URL' => 'Webmail Alias',
565565
'MySQL Support' => 'MySQL Support',
566566
'phpMyAdmin URL' => 'phpMyAdmin URL',
567567
'PostgreSQL Support' => 'PostgreSQL Support',

web/inc/i18n/de.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@
559559
'MAIL Server' => 'MAIL Server',
560560
'Antivirus' => 'Antivirus',
561561
'AntiSpam' => 'AntiSpam',
562-
'Webmail URL' => 'Webmail URL',
562+
'Webmail URL' => 'Webmail Alias',
563563
'MySQL Support' => 'MySQL Support',
564564
'phpMyAdmin URL' => 'phpMyAdmin URL',
565565
'PostgreSQL Support' => 'PostgreSQL Support',

web/inc/i18n/el.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
'MAIL Server' => 'MAIL Server',
562562
'Antivirus' => 'Antivirus',
563563
'AntiSpam' => 'AntiSpam',
564-
'Webmail URL' => 'Webmail URL',
564+
'Webmail URL' => 'Webmail Alias',
565565
'MySQL Support' => 'MySQL Support',
566566
'phpMyAdmin URL' => 'phpMyAdmin URL',
567567
'PostgreSQL Support' => 'PostgreSQL Support',

0 commit comments

Comments
 (0)