chaitanya
chaitanya

Reputation: 1

How to add multiple users in Yocto based on machine

I have 5 machines in my Yocto workspace. Is there a way to add users based on machine type?

For example:

Upvotes: 0

Views: 928

Answers (1)

justinsg
justinsg

Reputation: 848

The useradd-example.bb recipe demonstrates how to write a recipe that creates multiple users, each in their own package.

First, you could follow that example's pattern to create packages for each of the users you need:

# customusers.bb
inherit useradd

PACKAGES =+ "${PN}-user1 ${PN}-user2 ${PN}-user3"
USERADD_PACKAGES = "${PN}-user1 ${PN}-user2 ${PN}-user3"

USERADD_PARAM_${PN}-user1 = "-u 1001 -d /home/user1 -r user1"
USERADD_PARAM_${PN}-user2 = "-u 1002 -d /home/user2 -r user1"
USERADD_PARAM_${PN}-user3 = "-u 1003 -d /home/user3 -r user1"

Then, in each machine.conf file you can add the appropriate packages using MACHINE_ESSENTIAL_EXTRA_RDEPENDS, e.g.:

# machine1.conf
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "\
    customusers-user1 \
    customusers-user2 \
"
# machine2.conf
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "\
    customusers-user1 \
    customusers-user2 \
    customusers-user3 \
"

Upvotes: 2

Related Questions