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

Posted on Oct 23, 2014

Script for populating /etc/virtual/domainips records for the exim.
Exim configuration change is described [here][2]
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!!!):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/bin/sh

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
	fi
done

exit 0;

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