View Full Version : Collecting all domains on the server

08-10-2005, 11:58 PM
In order to collect a list of all domains on the server to do a comparison before accepting an order here's what I do since there's no command to get a list of ALL domains on the server:

Collect a list of all users, resellers, admin's.
Then foreach user, reseller, and admin I get a list of domains and add them to a master domains list.
Finally I do the comparison.

There are 3 initial queries to get the complete list of occupants. Then an additional query for each occupant found.
With only a handful of occupants this is a lot of queries needed to be run through the API to get the necassary information to make a complete comparison.
On my test server with under 20 occupants, it is already well on it's way to reaching the customers tolerance level of impatience.

Currently, my only alternative that I have thought of so far is to synchronize my accounting program with DirectAdmin on a scheduled bases where time isn't as much an issue.
Then in my signup script I can confidentally use the list of domains provided from a single mysql query, which would be much faster.
Or Create the account off the bat letting DirectAdmin do all the checking (not sure on speed), then suspend the account until payment is recieved vs. creating the account only upon zero balance.

Just wanted to pick at your brains.
Any other ideas?

08-11-2005, 08:50 AM
Or you could just look at the /var/named directory get all the filenames, strip the .db off the end and you have a complete list of domains on the server :)

Even easier is to get a list of /etc/virtual each domain name has a directory or symbolic link listed here.

And the 3rd and easiest option is to read the file /etc/virtual/domains. This file contains a list of all domains on the system 1 per line.


08-11-2005, 09:21 AM
Thanks for the suggestions, I'll take a look later tonight and check if apache has the necassary permissions to read these files/directories since this script will not be running with elevated privileges.

08-11-2005, 03:30 PM

If apache is running as the apache user on your system(s) you can just add the apache user to the group (in /etc/group) that owns and has read rights to the file you've decided to use.

There's another way:

ls /home/*/domains/*

But it will only get you real domains; it won't get subdomains or alias domains.