If you want to keep a server at sane operating limits, you can prevent Users and Reseller from adding more domains by using the all_pre.sh script. Note this will not apply to Admin's creating Rsellers (unless you want it to, just add the code). Also backup restores are not checked by this script.. it's mainly only as a reminder that the limit is reached. Also, the limit being checked is counted with the tally daily, so if a user adds 50 domains when thel limit is a 195, the block won't be imlemented until after that count is tallied at midnight. You can change the limit of 200 to any value you want.
Create the script:
/usr/local/directadmin/scirpts/custom/all_pre.sh
in it, place the following code:
#!/bin/sh
MAX_DOMAINS=200
CREATING_DOMAIN=0
if [ "$command" = "/CMD_ACCOUNT_USER" ] && [ "$action" = "create" ]; then
CREATING_DOMAIN=1
fi
if [ "$command" = "/CMD_DOMAIN" ] && [ "$action" = "create" ]; then
CREATING_DOMAIN=1
fi
if [ $CREATING_DOMAIN -eq 1 ]; then
CURRENT_COUNT=`cat /usr/local/directadmin/data/admin/admin.usage | grep vdomains | cut -d= -f2`
if [ "$CURRENT_COUNT" -ge $MAX_DOMAINS ]; then
echo "server is currently at it's limit of $MAX_DOMAINS";
exit 1;
fi
fi
exit 0;
Save/exit, and chmod the all_pre.sh script to 755.
Create the script:
/usr/local/directadmin/scirpts/custom/all_pre.sh
in it, place the following code:
#!/bin/sh
MAX_DOMAINS=200
CREATING_DOMAIN=0
if [ "$command" = "/CMD_ACCOUNT_USER" ] && [ "$action" = "create" ]; then
CREATING_DOMAIN=1
fi
if [ "$command" = "/CMD_DOMAIN" ] && [ "$action" = "create" ]; then
CREATING_DOMAIN=1
fi
if [ $CREATING_DOMAIN -eq 1 ]; then
CURRENT_COUNT=`cat /usr/local/directadmin/data/admin/admin.usage | grep vdomains | cut -d= -f2`
if [ "$CURRENT_COUNT" -ge $MAX_DOMAINS ]; then
echo "server is currently at it's limit of $MAX_DOMAINS";
exit 1;
fi
fi
exit 0;
Save/exit, and chmod the all_pre.sh script to 755.
No comments:
Post a Comment