|
17 | 17 |
|
18 | 18 | # Populating HELO/SMTP Banner for existing IPs |
19 | 19 | if [ "$MAIL_SYSTEM" == "exim4" ]; then |
20 | | - source $HESTIA/func/ip.sh |
21 | 20 |
|
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 |
24 | 23 |
|
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 |
27 | 25 |
|
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 |
32 | 36 |
|
33 | | - # Update exim configuration |
34 | | - echo "[ * ] Updating exim4 configuration..." |
| 37 | + # Update exim configuration |
| 38 | + echo "[ * ] Updating exim4 configuration..." |
35 | 39 |
|
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 |
38 | 41 | 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 |
40 | 42 |
|
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 |
42 | 46 | fi |
43 | 47 |
|
44 | 48 | # Upgrading Mail System |
|
0 commit comments