Ok, so I have a whole new improved method. The following will use a script triggered by the post hooks to check "/usr/local/cpanel/etc/exim/replacecf/dkim/remote_smtp" and add custom lines to it if they do not exist. It will not modify existing custom lines so if new parameters are added, they'll will need to be manually implemented. However as long as you update your new "exim_custom_remote_smtp.conf" file with the same changes, they will be re-added in the future if an update removes them. That's the primary point of this is to make the changes persist through updates.
In your /etc/ folder create a file called:
exim_custom_remote_smtp.conf
Add the following lines to it (you can insert additional lines if there's other parameters you want added:
Code:
#remote_smtp_insert_start
connection_max_messages = 20
#remote_smtp_insert_end
Also in /etc/ crearte a file called:
exim_custom_remote_smtp.sh
Set the permissions to be executable.
Add the following code to it:
Bash:
#!/bin/sh
#This script will check your existing REMOTE_SMTP file and add your custom line if they do not already exist.
#This script is not meant to modify existing custom lines, only add them.
#if you add new lines to your CUSTOM_LINES file afer they already exist in your REMOTE_SMTP file, then you will need to manually add them there as well the first time
#set the file path for the file that contains just your custom lines
CUSTOM_LINES="/etc/exim_custom_remote_smtp.conf"
#set the file path for the file being modified /usr/local/cpanel/etc/exim/replacecf/dkim/remote_smtp
#you can copy this path to a test file such as /etc/exim_custom_remote_smtp_test and set it here
REMOTE_SMTP="/usr/local/cpanel/etc/exim/replacecf/dkim/remote_smtp"
#check if CUSTOM_LINES file exists or is empty.
if [ -s $CUSTOM_LINES ]; then
#check if REMOTE_SMTP file exists or is empty.
if [ -s $REMOTE_SMTP ]; then
echo "Checking if remote_smtp needs custom lines added"
#check if any of the lines already exist and if they do not add them and rebuild exim
CUSTOM_LINES_EXIST="$(grep -f $CUSTOM_LINES $REMOTE_SMTP)"
if [ -z "$CUSTOM_LINES_EXIST" ]; then
sed -i '/driver = smtp/a \\' $REMOTE_SMTP; sed -i "/driver = smtp/r $CUSTOM_LINES" $REMOTE_SMTP
echo "Custom lines were added for remote_smtp"
/scripts/buildeximconf
fi
else
echo "$REMOTE_SMTP NOT FOUND OR EMPTY"
fi
else
echo "$CUSTOM_LINES NOT FOUND OR EMPTY"
fi
Go to /scripts/ and edit or create the following 2 files:
posteximup
postupcp
I've added the following to these files so they run whenever cpanel or exim updates and if the remote_smtp file was modified removing the custom lines, they should get added back in without concern for any exim.conf version and other changes, including manual changes within WHM Exim Configuration.
Code:
/bin/sh /etc/exim_custom_remote_smtp.sh
If everything is setup correctly, you can run "/scripts/postupcp" to test. You should run it at least once to add the lines for you to the remote_smtp file and to make sure everything is set correctly.
If it's the first time adding the lines, You'll get output stating:
Checking if remote_smtp needs custom lines added
Custom lines were added for remote_smtp
(and then standard output triggered by Exim rebuilding)
If the lines already exist and you run postupcp again it will only output:
Checking if remote_smtp needs custom lines added
Comments in the script explain how to customize if you prefer to test with another file first. I've tested it on my system.
So, this should work much better than replacing the exim.conf as I was doing before and should persist as best as I can foresee now.