|
|
@@ -47,13 +47,15 @@ is_ip_rdns_valid() {
|
|
|
update_ip_helo_value() {
|
|
|
ip="$1"
|
|
|
helo="$2"
|
|
|
-
|
|
|
+ natip="$1"
|
|
|
+
|
|
|
+ # In case the IP is an NAT use the real ip address
|
|
|
+ if [ ! -f $HESTIA/data/ips/$ip ]; then
|
|
|
+ ip=$(get_real_ip $ip);
|
|
|
+ fi
|
|
|
+
|
|
|
# Create or update ip value
|
|
|
- if [ ! $(get_ip_value '$HELO') ]; then
|
|
|
- echo "HELO='$helo'" >> $HESTIA/data/ips/$ip
|
|
|
- else
|
|
|
- update_ip_value '$HELO' "$helo"
|
|
|
- fi
|
|
|
+ update_ip_value_new 'HELO' "$helo"
|
|
|
|
|
|
# Create mailhelo.conf file if doesn't exist
|
|
|
if [ ! -e "/etc/${MAIL_SYSTEM}/mailhelo.conf" ]; then
|
|
|
@@ -62,13 +64,13 @@ update_ip_helo_value() {
|
|
|
|
|
|
#Create or update ip:helo pair in mailhelo.conf file
|
|
|
if [ ! -z "$helo" ]; then
|
|
|
- if [ $(cat /etc/${MAIL_SYSTEM}/mailhelo.conf | grep "$ip") ]; then
|
|
|
- sed -i "/^$ip:/c $ip:$helo" /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
+ if [ $(cat /etc/${MAIL_SYSTEM}/mailhelo.conf | grep "$natip") ]; then
|
|
|
+ sed -i "/^$natip:/c $natip:$helo" /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
else
|
|
|
- echo $ip:$helo >> /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
+ echo $natip:$helo >> /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
fi
|
|
|
else
|
|
|
- sed -i "/^$ip:/d" /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
+ sed -i "/^$natip:/d" /etc/${MAIL_SYSTEM}/mailhelo.conf
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
@@ -87,6 +89,19 @@ update_ip_value() {
|
|
|
$conf
|
|
|
}
|
|
|
|
|
|
+# New method that is improved on a later date we need to check if we can improve it for other locations
|
|
|
+update_ip_value_new() {
|
|
|
+ key="$1"
|
|
|
+ value="$2"
|
|
|
+ conf="$HESTIA/data/ips/$ip"
|
|
|
+ check_ckey=$(grep "^$key='" $conf)
|
|
|
+ if [ -z "$check_ckey" ]; then
|
|
|
+ echo "$key='$value'" >> $conf
|
|
|
+ else
|
|
|
+ sed -i "s|^$key=.*|$key='$value'|g" $conf
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
# Get ip name
|
|
|
get_ip_alias() {
|
|
|
ip_name=$(grep "NAME=" $HESTIA/data/ips/$local_ip |cut -f 2 -d \')
|