Script: populating the domainips file for the exim automatically (DirectAdmin)

Script for populating /etc/virtual/domainips records for the exim.
Exim configuration change is described here
It takes IP that is assigned to that domain in Directadmin and adds it to the domainsip file.

Here is the script (Please note: it always overwrites the domainips file!!!):


LIST=`/bin/cat /etc/virtual/domainowners | tr -d ' '`
echo -n '' > /etc/virtual/domainips

for LINE in $LIST; do
	USER=`echo $LINE | cut -d: -f2`
	DOMAIN=`echo $LINE | cut -d: -f1`
	if [ -f "/usr/local/directadmin/data/users/$USER/domains/$DOMAIN.conf" ]; then
		IP=`/bin/grep 'ip=' /usr/local/directadmin/data/users/$USER/domains/$DOMAIN.conf | cut -f2 -d=`
		[ -z $IP ] || echo "$DOMAIN: $IP" >> /etc/virtual/domainips

exit 0;

note: You may add this script to cron, for automatic ‘domainips’ updates.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.