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

by

in

shell-linux
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!!!):

#!/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.



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

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