public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] doc: document how to best populate users home dirs and add example
@ 2020-01-15 17:09 Henning Schild
  2020-01-16 10:02 ` Jan Kiszka
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Henning Schild @ 2020-01-15 17:09 UTC (permalink / raw)
  To: isar-users; +Cc: Q . Gylstorff, Henning Schild

From: Henning Schild <henning.schild@siemens.com>

People that create users often also end up wanting to place content in
their home. Add a short section on how to best do that, including an
example implementation in example-raw.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 doc/user_manual.md                                  | 11 +++++++++++
 .../recipes-app/example-raw/example-raw_0.3.bb      |  5 +++++
 meta-isar/recipes-app/example-raw/files/postinst    | 13 +++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index d501a706..8f5bc936 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -546,6 +546,17 @@ The `USERS` and `USER_<username>` variable works similar to the `GROUPS` and `GR
    - `system` - `useradd` will be called with `--system`.
    - `allow-empty-password` - Even if the `password` flag is empty, it will still be set. This results in a login without password.
 
+#### Home directory contents prefilling
+
+To cover all users simply use `/etc/skel`. Files in there will be available in every home directory under correct permissions.
+If you have just one user you might end up abusing this for large content, that is a waste of space.
+
+To place content into specific homes drop those files into position and create the user and possibly group in `postinst`. Now you can chown the contents because the user is known.
+
+The regular user and group configuration will still apply later, it will just change an existing user.
+
+meta-isar/recipes-app/example-raw contains an example
+
 ---
 
 ## Create a Custom Image Recipe
diff --git a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
index d9f3a2e9..cc0d0591 100644
--- a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
+++ b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
@@ -31,4 +31,9 @@ do_install() {
 	echo "# empty config file" > ${WORKDIR}/${PN}.conf
 	install -v -d ${D}/etc/
 	install -v -m 644 ${WORKDIR}/${PN}.conf ${D}/etc/${PN}.conf
+
+	bbnote "A user-specific HOME entry"
+	echo "hello isar" > ${WORKDIR}/${PN}-isar.txt
+	install -v -d ${D}/var/lib/isar/
+	install -v -m 644 ${WORKDIR}/${PN}-isar.txt ${S}/var/lib/isar/
 }
diff --git a/meta-isar/recipes-app/example-raw/files/postinst b/meta-isar/recipes-app/example-raw/files/postinst
index 416ff349..f48d993c 100644
--- a/meta-isar/recipes-app/example-raw/files/postinst
+++ b/meta-isar/recipes-app/example-raw/files/postinst
@@ -2,4 +2,17 @@
 
 set -e
 
+if ! getent group isar >/dev/null; then
+	addgroup --quiet --system isar
+fi
+
+if ! getent passwd isar >/dev/null; then
+	useradd --system --gid isar --create-home \
+		--home /var/lib/isar --no-user-group \
+		--comment "My isar user" \
+		isar
+fi
+
+chown -R isar:isar /var/lib/isar
+
 echo "isar" > /etc/hostname
-- 
2.24.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-09 11:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 17:09 [PATCH] doc: document how to best populate users home dirs and add example Henning Schild
2020-01-16 10:02 ` Jan Kiszka
2020-01-24 19:51 ` Henning Schild
2020-01-27 15:45 ` [PATCHv2] " Henning Schild
2020-01-27 15:46   ` Henning Schild
2020-03-09 11:04   ` Baurzhan Ismagulov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox