Create a report of all domain names and their creation date

MaltaCode

Verified User
Joined
Dec 9, 2020
Messages
9
Location
Xaghra, Gozo, Malta
I would like to create a report (or export) of all domain names on my server with their creation date. I've seen some shell scripting here on creating a list of domain names but am not sure how I can add the creation date in there.
 
I see where users' creation dates ('date_created') are stored in the user.conf files, but not domains:


Code:
[root@host domains]# cat domain.tld.conf
UseCanonicalName=OFF
active=yes
bandwidth=unlimited
cgi=ON
defaultdomain=yes
domain=domain.tld
ip=108.RED.ACT.ED
open_basedir=OFF
php=ON
php1_select=1
php2_select=0
quota=unlimited
safemode=OFF
ssl=ON
suspended=no
username=admin
[root@host domains]#

If you are aware of this information being stored elsewhere, then let me know and we could put something together using that.

Otherwise, you might create a post- domain creation script and use it to start a log to log the date and time following domain creation, and then use custom log this to draft your list. Remember to add the same code for domains, subdomains, and pointers.

/usr/local/directadmin/scripts/custom/domain_create_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
echo "domain $domain created by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_creation.log
exit 0;

/usr/local/directadmin/scripts/custom/subdomain_create_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
echo "subdomain $subdomain.$domain created by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_creation.log
exit 0;

/usr/local/directadmin/scripts/custom/domain_pointer_create_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
echo "domain pointer $domain from $from created by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_creation.log
exit 0;

Then, just cat the log for a list of all domains and their creation dates and times.


In the same respect, you may want to also create a log for domain deletions just the same.

/usr/local/directadmin/scripts/custom/domain_destroy_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
andcontent=`if [[ contents -eq 1 ]]; then echo "and its contents"; else echo 'but not its contents'; fi`
echo "domain $domain $andcontent removed by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_removal.log
exit 0;

/usr/local/directadmin/scripts/custom/subdomain_destroy_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
andcontent=`if [[ contents -eq 1 ]]; then echo "and its contents"; else echo 'but not its contents'; fi`
echo "subdomain $subdomain.$domain $andcontent removed by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_removal.log
exit 0;

/usr/local/directadmin/scripts/custom/domain_pointer_destroy_post/logging.sh
Code:
#!/bin/bash
date=`date`
logged_in_as=`if [[ IS_LOGIN_AS -ne 1 ]]; then echo $username; else echo $LOGIN_AS_MASTER; fi`
andcontent=`if [[ contents -eq 1 ]]; then echo "and its contents"; else echo 'but not its contents'; fi`
echo "domain pointer $domain from $from $andcontent removed by $username (logged in as $logged_in_as) at $caller_ip on $date"  >> /var/log/domain_removal.log
exit 0;


Note, if the directories above do not exist, create them using the command 'mkdir -p /usr/local/directadmin/scripts/custom/..........'
chmod to 700 and chown to diradmin.diradmin. :)
 
Hi (Script)Kitty, thank you, this helps. I thought in the past I did see a creation date of domains, but now I can't find it anymore in directadmin. So I must have located it elsewhere. I will create the scripts because they are useful.
 
you can check creation date for domain directory, or named zone file
 
Back
Top