Adding user to a group while a site is created

hajagha

Verified User
Joined
Dec 9, 2008
Messages
10
Hi,
I want to limit some of server sources for my clients. If I use for example RlimitCPU, Apache will limit user apache too! So I want to create a group (e.g myclients) and whenever myself or my resellers, create a site for a customer, it's username is added to that group automatically.

If I have to pay for this script, please let me know the price.

Thanks,
Alireza
 
Create /usr/local/directadmin/scripts/custom/user_create_post.sh

And add the following code to it:

Code:
#!/bin/sh
usermod -a -G myclients $username

exit 0;
 
Thanks for your reply, but it didn't work!

I careated a group named myclients, then I created user_create_post.sh in the location you mentioned and copied the command in to it. After this I changed the owner of the file to diradmin (but not the permissons).
After I created an account, I typed the command below in shell:
[root@server3 custom]# groups alireza
alireza : alireza
[root@server3 custom]#
As you see, the user did not add to the group.

What should I do now?

Alireza
 
Hi,

Thank you both for helping me.
As I've started learning linux, I have to search your replies to understand what you said!

I added code below at the end of the code to see the output of the script:
Code:
 2>&1 | tee file.txt

but there was no output! So I guessed that maybe the script is not run at all so I changed its permission to 777 and then, after creation a user, the script was run.

So would you please tell me the correct owner and permission of the script as I think that 777 is dangerous!

Thanks again,
Alireza
 
I mean what is the correct permission and owner of the file user_create_post.sh?
the script works fine with permission 777 and owner diradmin. But I think permission 777 is dangerous.

Alireza
 
No ouput in file.txt is caused by the fact that you don't use full path to the file.txt. Script is executed from superuser root name. Thus in most case 700 permissions would be enough.
 
Back
Top