From 0c027f613039db54bc87fb6de63c0ffe253cabf2 Mon Sep 17 00:00:00 2001 From: unitexe Date: Mon, 23 Feb 2026 08:25:47 -0600 Subject: Introduce meta-unit-virtualization Primary motivation for this is removing observability containers from beaglebone black because of RAM limitations. Images can now include the observability containers by adding `observability` to `IMAGE_FEATURES`. --- .../recipes-users/useradd/add-user-svc.bb | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 meta-unit-virtualization/recipes-users/useradd/add-user-svc.bb (limited to 'meta-unit-virtualization/recipes-users/useradd') diff --git a/meta-unit-virtualization/recipes-users/useradd/add-user-svc.bb b/meta-unit-virtualization/recipes-users/useradd/add-user-svc.bb new file mode 100644 index 0000000..dbbc0c5 --- /dev/null +++ b/meta-unit-virtualization/recipes-users/useradd/add-user-svc.bb @@ -0,0 +1,43 @@ +SUMMARY = "Add service user" +LICENSE = "MIT" + +EXCLUDE_FROM_WORLD = "1" + +inherit useradd +inherit extrausers +inherit enable-linger +inherit set-xdg-env + +RDEPENDS:${PN}:append = " base-passwd" +RDEPENDS:${PN}:append = " busybox" +RDEPENDS:${PN}:append = " shadow" +RDEPENDS:${PN}:append = " systemd" + +USERADD_PACKAGES = "${PN}" + +USER_TO_ADD_NAME ?= "svc" +USER_TO_ADD_UID ?= "50556" +USER_TO_ADD_PASSWORD_HASHED ?= "\$6\$1TQs7iLskyTyCjoL\$xhngcFWaPRsoaZCwLSsYXUrRcVdR19zV2vBEzrzSEVu8zbqDlfKu4HLwzsZfiqJCiWqiu9qirD4Ym12CMf7D7." +COMMA_SEPARATED_LIST_OF_GROUPS_TO_ADD_USER_TO ?= "systemd-journal" + +USERADD_PARAM:${PN} = "-u ${USER_TO_ADD_UID} -d /home/${USER_TO_ADD_NAME} -s ${base_bindir}/sh -G ${COMMA_SEPARATED_LIST_OF_GROUPS_TO_ADD_USER_TO} -p '${USER_TO_ADD_PASSWORD_HASHED}' ${USER_TO_ADD_NAME}" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +do_install() { + # Note: Use of .profile here assumes busybox shell. + install -D -m 0644 /dev/null ${D}/home/${USER_TO_ADD_NAME}/.profile + + # User is not part of sudo group and therefore doesn't + # have sbin in path, add it for access to common commands. + cat > ${D}/home/${USER_TO_ADD_NAME}/.profile << 'EOF' +export PATH="${sbindir}:/sbin:$PATH" +EOF +} + +# Prior to useradd being performed on the sysroot a couple things must happen: +# 1. Need the systemd recipe to create the systemd-journal group +# 2. Need busybox shell present +do_prepare_recipe_sysroot[depends] += "systemd:do_populate_sysroot busybox:do_populate_sysroot" + +FILES:${PN}:append = " /home/${USER_TO_ADD_NAME}/.profile" -- cgit v1.2.3