Skip to content

Commit 80f0e4c

Browse files
committed
Fixes mail helo issue in upgrade script
1 parent e088f4c commit 80f0e4c

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

install/upgrade/versions/1.4.0.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,32 @@ fi
1717

1818
# Populating HELO/SMTP Banner for existing IPs
1919
if [ "$MAIL_SYSTEM" == "exim4" ]; then
20-
source $HESTIA/func/ip.sh
2120

22-
echo "[ * ] Populating HELO/SMTP Banner value for existing IP addresses..."
23-
> /etc/exim4/mailhelo.conf
21+
# Check if we've already done this upgrade before proceeding
22+
if ! grep -q ^smtp_active_hostname /etc/exim4/exim4.conf.template; then
2423

25-
for ip in $($BIN/v-list-sys-ips plain | cut -f1); do
26-
helo=$(is_ip_rdns_valid $ip)
24+
source $HESTIA/func/ip.sh
2725

28-
if [ ! -z "$helo" ]; then
29-
$BIN/v-change-sys-ip-helo $ip $helo
30-
fi
31-
done
26+
echo "[ * ] Populating HELO/SMTP Banner value for existing IP addresses..."
27+
> /etc/exim4/mailhelo.conf
28+
29+
for ip in $($BIN/v-list-sys-ips plain | cut -f1); do
30+
helo=$(is_ip_rdns_valid $ip)
31+
32+
if [ ! -z "$helo" ]; then
33+
$BIN/v-change-sys-ip-helo $ip $helo
34+
fi
35+
done
3236

33-
# Update exim configuration
34-
echo "[ * ] Updating exim4 configuration..."
37+
# Update exim configuration
38+
echo "[ * ] Updating exim4 configuration..."
3539

36-
# Check if smtp_active_hostname exists before adding it
37-
if [ ! 'grep -q ^smtp_active_hostname /etc/exim4/exim4.conf.template' ]; then
40+
# Add new smtp_active_hostname variable to exim config
3841
sed -i '/^smtp_banner = \$smtp_active_hostname$/a smtp_active_hostname = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$interface_address}lsearch{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}"' /etc/exim4/exim4.conf.template
39-
fi
4042

41-
sed -i 's/helo_data = \${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{\$sender_address_domain}lsearch\*{\/etc\/exim4\/mailhelo.conf}{\$value}{\$primary_hostname}}}{\$primary_hostname}}/helo_data = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$sending_ip_address}lsearch{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}/' /etc/exim4/exim4.conf.template
43+
# Lookup HELO address by sending ip instead of sending domain
44+
sed -i 's/helo_data = \${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{\$sender_address_domain}lsearch\*{\/etc\/exim4\/mailhelo.conf}{\$value}{\$primary_hostname}}}{\$primary_hostname}}/helo_data = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$sending_ip_address}lsearch{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}/' /etc/exim4/exim4.conf.template
45+
fi
4246
fi
4347

4448
# Upgrading Mail System

0 commit comments

Comments
 (0)