Skip to content

Commit b6baa15

Browse files
authored
1 parent ed36307 commit b6baa15

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

bin/v-change-domain-owner

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if [ -n "$web_data" ]; then
7373
new_php_docroot=$(echo $CUSTOM_PHPROOT | sed "s/\/home\/$owner/\/home\/$user/");
7474
fi
7575
fi
76-
76+
7777
if [ -z "$(echo $(get_user_ips) | grep $IP)" ]; then
7878
echo "[*] IP dedicated to $owner select new ip adress..."
7979
get_user_ip
@@ -170,6 +170,7 @@ fi
170170
# MAIL domain
171171
mail_data=$(grep "DOMAIN='$domain'" $HESTIA/data/users/$owner/mail.conf)
172172
if [ -n "$mail_data" ]; then
173+
$BIN/v-suspend-mail-domain "$owner" "$domain" >> /dev/null 2>&1
173174
echo "[*] Moving mail domain and accounts..."
174175

175176
parse_object_kv_list "$mail_data"
@@ -181,6 +182,7 @@ if [ -n "$mail_data" ]; then
181182

182183
# Move config
183184
sed -i "/DOMAIN='$domain'/d" $HESTIA/data/users/$owner/mail.conf
185+
mail_data=$(echo "$mail_data" | sed "s/SUSPENDED='no'/SUSPENDED='yes'/")
184186
echo "$mail_data" >> $HESTIA/data/users/$user/mail.conf
185187
mv -f $HESTIA/data/users/$owner/mail/$domain.conf \
186188
$HESTIA/data/users/$user/mail/
@@ -192,7 +194,7 @@ if [ -n "$mail_data" ]; then
192194
mv -f $HESTIA/data/users/$owner/mail/$domain.pub \
193195
$HESTIA/data/users/$user/mail/
194196
fi
195-
197+
196198
# Move SSL certificates
197199
if [ "$SSL" = 'yes' ]; then
198200
# Ensure that SSL directory exists and move certificates
@@ -274,7 +276,6 @@ if [ -n "$mail_data" ]; then
274276
if [ -e "$HESTIA/data/users/$owner/mail/$domain.conf" ]; then
275277
rm -f "$HESTIA/data/users/$owner/mail/$domain.conf"
276278
fi
277-
278279

279280
# Rebuild config
280281
$BIN/v-unsuspend-mail-domain "$user" "$domain" no
@@ -286,14 +287,17 @@ fi
286287
$BIN/v-update-user-counters "$owner"
287288
$BIN/v-update-user-counters "$user"
288289

289-
# Recalculate ip usage
290-
if [ -n "$ip" ]; then
291-
decrease_ip_value $old_ip $owner
292-
increase_ip_value $new_ip
293-
else
294-
# recalculate ip
295-
decrease_ip_value $old_ip $owner
296-
increase_ip_value $old_ip
290+
# Mail domains currently don't have the IP variable set see #2306
291+
if [ -n "$old_ip" ]; then
292+
# Recalculate ip usage
293+
if [ -n "$ip" ]; then
294+
decrease_ip_value $old_ip $owner
295+
increase_ip_value $new_ip
296+
else
297+
# recalculate ip
298+
decrease_ip_value $old_ip $owner
299+
increase_ip_value $old_ip
300+
fi
297301
fi
298302
# Send notification to panel
299303
if [ -n "$web_data" ] || [ -n "$dns_data" ] || [ -n "$mail_data" ]; then

0 commit comments

Comments
 (0)