Using domain_create_pre.sh to limit the number of domains allowed on a server


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DirectAdmin » Custom Scripting

Using domain_create_pre.sh to limit the number of domains allowed on a serverLast Modified: May 31, 2012, 2:57 pm
If you want to cap the number of domains created on the server, you can use the domain_create_pre.sh to do so.
In this example, we'll see a maximum number of 10 domains, but you can change this number as desired.

1) Create the following file:

/usr/local/directadmin/scripts/custom/domain_create_pre.sh

In that script, add the code:

#!/bin/sh
MAX_DOMAINS=10

#obtains the exact number of domains on the system right now.  The tally is delayed, and cannot be used.
CURRENT=`ls -la /etc/virtual/ | grep drwx | grep -v majordomo | grep -v usage | grep -c drwx`

if [ "$CURRENT" -ge "$MAX_DOMAINS" ]; then
       echo "Maximum number of domains ($MAX_DOMAINS) has already been created.  Cannot create any more."
       exit 1;
fi
exit 0;


2) chmod the script to 755:

chmod 755 /usr/local/directadmin/scripts/custom/domain_create_pre.sh


3) You may want to run this script before user creation as well (domain_create_pre.sh is after the user is already created), so just create a link to it:

cd /usr/local/directadmin/scripts/custom
ln -s domain_create_pre.sh user_create_pre.sh


 
Related Helpfiles
Limit the number of Users a Reseller can create

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST