public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: "Q . Gylstorff" <Quirin.Gylstorff@siemens.com>,
	Henning Schild <henning.schild@siemens.com>
Subject: [PATCH] doc: document how to best populate users home dirs and add example
Date: Wed, 15 Jan 2020 18:09:54 +0100	[thread overview]
Message-ID: <20200115170954.20235-1-henning.schild@siemens.com> (raw)

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


             reply	other threads:[~2020-01-15 17:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 17:09 Henning Schild [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200115170954.20235-1-henning.schild@siemens.com \
    --to=henning.schild@siemens.com \
    --cc=Quirin.Gylstorff@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox