How to auto put new HestiaCP user to a group?

To run Redis as Unix Socket instead of default TCP. I have to create a group and put all users into that one so they will have permission to read/write.

I usually manually add a user to the group with this command:
sudo usermod -a -G redisusergroup user1

However, I am looking for a better way to auto-add new HestiaCP user to that group. Is it possible?

I tried to create a file /etc/adduser.conf with config

EXTRA_GROUPS="redisusergroup"
ADD_EXTRA_GROUPS=1

But doesn’t work. When I created a new user in HestiaCP, it didn’t add that user to the group.

Please advise.

Thanks

Just run redis under hestiausers group is easier …

Does that mean we have to put redis into the multiple hestiausers group?

Is there an automatic way to do it?

Yes it means to run redis under the hostiausers group

Other option is to create /usr/local/hestia/data/packages/package.sh where package.sh = package.pkg and give it +x permissions

When applying the package the script will run:

1 Like

Could you please help write the command in package.sh?

I have no idea how to write the command for it OR just put the code above inside it?

Thanks for your help

#/bin/bash

user=$1
usermod -a -G redisusergroup “$user”

1 Like

I created the file package.sh at /usr/local/hestia/data/packages/package.sh

and chmod +x package.sh

user=$1
usermod -a -G redisuser "$user"
newgrp redisuser

Then, I went to HestiaCP and created a new user but the user didn’t display in the group when I ran command: getent group redisuser

Please help
Thanks for your time!

You must add the shebang to package.sh script:

#!/bin/bash
user=$1
usermod -a -G redisuser "$user"

or

#!/usr/bin/env bash
user=$1
usermod -a -G redisuser "$user"

You don’t need to add newgrp redisuser

1 Like

I forgot to quote here but I did in the file. The complete content of the file is:

#!/bin/bash
user=$1
usermod -a -G redisuser "$user"

But nothing happened after I created a user in HestiaCP. No user has been put into the redisuser group.

Show the output of this command:

ls -la /usr/local/hestia/data/packages/
total 12
drwxr-xr-x  2 root root  61 Dec  4 09:24 .
drwxr-xr-x 11 root root 137 Nov 30 14:07 ..
-rw-r--r--  1 root root 550 Nov 30 14:17 default.pkg
-rwxr-xr-x  1 root root  52 Dec  4 09:15 package.sh
-rw-r--r--  1 root root 564 Nov 30 14:07 system.pkg

Here it is. Thanks

Ok, I see the problem.

Keep in mind that the script name must match the package name, not be literally package.sh. For example, if the package name is default, the script should be named default.sh.

2 Likes

it’s working now. Thanks so much for your help @sahsanu and @eris

1 Like

@eris if we use your simple/intelligent solution, add redis user to new created group.
What is the default.sh content should be? Can you help?

Thanks

The you can leave it empty …

Because hestiausers group exists by default

But when we add a new user (example) for website example.com. The files will be owned by example:example and we have to put redis user into example group, right?

We need a script to auto-put redis user to the newly created group!?

Please let me know If I am wrong.

Thanks

No we run php under user so it has access to the hostiausers group by default

I am sorry. I still do not understand how to do what you said above. Could you please help explain this clearly?

Thank you, Eris

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.