When shell user is created, add them to a group

Discussion in 'Installation/Configuration' started by CarlBeckel, Aug 29, 2013.

  1. CarlBeckel

    CarlBeckel New Member

    When I create a shell user in ISPConfig 3 I would like to automatically add that user to a custom group I've created.

    What's the best way to achieve this?
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    If you want to have a update save way, then the best way is to create a small server plugin that subscribes to the "shell_user_insert" event and runs the command to add the user to the group. the name of your custom plugin must be after the shell user plugins in alphabetical order. E.g. give him a name that starts with "x" like xcustomshelluser_plugin.inc.php. See shelluser_base_plugin.inc.php for an example of a plugin.
  3. CarlBeckel

    CarlBeckel New Member

    As reference for fellow ISPConfig noobs that file is located at:

    At least that's where it is on my system.

    Thanks for the reply, I'll try your suggestion. So once I figure out how to write the plugin I can just stick it in that directory or do I need to enable it somehow?

    Also, using a plugin like this, can I make it active by using the dropdown that activates jailkit? So for example when I create a new shell user my choices under chroot jail would be none, jailkit, or custom.

    I'm using this for a sftp only chroot jail without all the extra folders and files that jailkit adds so that would be ideal and would leave me the option to create regular shell users if needed.
    Last edited: Aug 29, 2013
  4. CarlBeckel

    CarlBeckel New Member

    Thanks again till, your solution worked great. If anyone else needs to do this here's what I did:

    1. Used the file mentioned as a base and modified to fit my needs.
    2. Uploaded that file to the plugins-available directory mentioned above
    3. Created a symlink to the file from /usr/local/ispconfig/server/plugins-enabled
    4. Made sure file ownership and permissions matched the other plugins and symlinks.
    5. Added a shell user and it worked! I'm attaching the code for anyone else who needs to do this or just wants to see how a simple plugin would work.

    Note: Plugins are apparently executed in alphabetical order, that's why this one starts with z.

    Attached Files:

  5. till

    till Super Moderator Staff Member ISPConfig Developer

    You would have to add the extra choice in the form file of the shell user in the interface. See /usr/local/ispconfig/interface/web/sites/form/ folder, but changes to these files will get overwritten on updates. In your plugin you get all values as multi dimensional array in the $data parameter.

Share This Page