Limit number of shared accounts a reseller can create

jj@24khost

Verified User
Joined
May 17, 2012
Messages
22
This allow for us to control overselling fo account numbers, this is already in cpanel looking for it here.
 
Well that is fine and dandy but depending on the plan it has a different amount of resellers, being able to specify this via the control panel woud be a major help.
 
I've actually to agree with the user.

John, a reseller can have different packages and each packages can allow less or more users, ofc for now should be a start, but maybe an implementation in package would be better (also i think is possible with custom value in packages and use that variable for the IF statement, but, a built-in should be better).

Ill investigate on custom variable once ive some free time and let know if that does work (i suppose yes with a little hand-work)

Regards
 
Ok, it can be done using those steps:

craete a file called:
Code:
/usr/local/directadmin/data/admin/custom_package_items.conf

and put inside it this line:
Code:
users_number=type=text&string=Users Number&desc=Number of users that can be created.

create this file:
Code:
/usr/local/directadmin/scripts/custom/user_create_pre.sh

and put this code:
Code:
#!/bin/sh

MAX_USERS='cat /usr/local/directadmin/data/users/$creator/user.conf | grep users_number | cut -d= -f2'

if [ "$usertype" != "user" ]; then

    exit 0;

fi

#obtains the exact number of domains on the system right now.  The tally is delayed, and cannot be used.
CURRENT=`wc -l /usr/local/directadmin/data/users/$creator/users.list | cut -d\  -f1`

if [ "$CURRENT" -ge "$MAX_USERS" ]; then

      echo "Maximum number of Users  ($MAX_USERS) have already been created.  Cannot create any more."
      exit 1;

fi

exit 0;

now set permissions, so:

Code:
chown diradmin:diradmin /usr/local/directadmin/scripts/custom/user_create_pre.sh
chown diradmin:diradmin /usr/local/directadmin/data/admin/custom_package_items.conf
chmod 700 /usr/local/directadmin/scripts/custom/user_create_pre.sh
chmod 644 /usr/local/directadmin/data/admin/custom_package_items.conf

Done, you will now have in package manager (on create) a value for set a limit of user-per-reseller.

When you will create a new reseller he will have a custom value in his user.conf (called users_number=)

The script will be called always before a user is created (if is not a user being created it will just exit) and will check the user.conf of the creator (reseller or admin no matter) and if limit is over will pop a message with this error "Maximum number of Users ($MAX_USERS) have already been created. Cannot create any more." where ofc MAX_USERS variable is the set of his limit.

Hope it help

Regards
 
Back
Top