2

Is there a way to perform additional tasks every time a new user is created with adduser(8) in FreeBSD?

To be more precise, i'd like to create a directory for every new user and map this user with pdbedit(8) to the SAM database.

Some Linux distributions like debian/ubuntu provide a handy way to solve this problem. If a script called /usr/local/sbin/adduser.local exists, it'll be executed after a new user has been created:

#!/bin/bash
mkdir /srv/samba/$1
chown $1:$2 /srv/samba/$1
chmod 775 /srv/samba/$1

How would I do this using FreeBSD?

kundev
  • 51
  • 5

1 Answers1

3

I followed Richard Smiths suggestion and solved my problem with a very simple shell script, which calls adduser(8) as well as pdbedit(8) and creates the corresponding directory.

#!/bin/sh

user=$1

# create user and add to SAM database
adduser $user
pdbedit -a $user

# create private samba directory
mkdir /srv/samba/$user
chown $user:$user /srv/samba/$user
chmod 775 /srv/samba/$user
kundev
  • 51
  • 5