mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Dahl <ada@thorsis.com>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH 2/2] mtd-utils: Introduce systemd unit for ubihealthd
Date: Thu,  9 Sep 2021 12:16:52 +0200	[thread overview]
Message-ID: <20210909101652.9288-3-ada@thorsis.com> (raw)
In-Reply-To: <20210909101652.9288-1-ada@thorsis.com>

It's possible to run multiple instances for multiple ubi devices by
creating multiple symlinks. One symlink for the first device ubi0 is
already created.

Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
 .../usr/lib/systemd/system/ubihealthd@.service      | 13 +++++++++++++
 rules/mtd-utils.in                                  | 12 +++++++++++-
 rules/mtd-utils.make                                |  6 ++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 projectroot/usr/lib/systemd/system/ubihealthd@.service

diff --git a/projectroot/usr/lib/systemd/system/ubihealthd@.service b/projectroot/usr/lib/systemd/system/ubihealthd@.service
new file mode 100644
index 000000000..f3f0ba25f
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/ubihealthd@.service
@@ -0,0 +1,13 @@
+# enable with `systemctl enable ubihealthd@ubi0.service`
+
+[Unit]
+Description=ubihealthd UBI device PEB scan daemon for %I
+BindsTo=dev-%i.device
+After=dev-%i.device
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/ubihealthd -d /dev/%I -i 120
+
+[Install]
+WantedBy=multi-user.target
diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
index 11b0be23f..0d8fb5f5a 100644
--- a/rules/mtd-utils.in
+++ b/rules/mtd-utils.in
@@ -294,13 +294,23 @@ config MTD_UTILS_UBIFS_MOUNTHELPER
 	help
 	  Simplifies attaching an ubi and mounting an ubifs via /etc/fstab.
 
-config MTD_UTILS_UBIHEALTHD
+menuconfig MTD_UTILS_UBIHEALTHD
 	bool
 	prompt "ubihealthd"
 	help
 	  Daemon that randomly scans each PEB of a UBI device to ensure that
 	  filesystems with little reading do enough wear leveling.
 
+if MTD_UTILS_UBIHEALTHD
+
+config MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT
+	bool
+	prompt "install systemd unit files"
+	default y
+	depends on SYSTEMD
+
+endif
+
 config MTD_UTILS_UBIMKVOL
 	bool
 	prompt "ubimkvol"
diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
index 15288acd7..d96ab02b0 100644
--- a/rules/mtd-utils.make
+++ b/rules/mtd-utils.make
@@ -205,6 +205,12 @@ endif
 ifdef PTXCONF_MTD_UTILS_UBIHEALTHD
 	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
 		/usr/sbin/ubihealthd)
+ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT
+	@$(call install_alternative, mtd-utils, 0, 0, 0644, \
+		/usr/lib/systemd/system/ubihealthd@.service)
+	@$(call install_link, mtd-utils, ../ubihealthd@.service, \
+		/usr/lib/systemd/system/multi-user.target.wants/ubihealthd@ubi0.service)
+endif
 endif
 ifdef PTXCONF_MTD_UTILS_UBIMKVOL
 	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
-- 
2.30.2


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de


  parent reply	other threads:[~2021-09-09 10:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 10:16 [ptxdist] [PATCH 0/2] mtd-utils: Version bump and ubihealthd systemd unit Alexander Dahl
2021-09-09 10:16 ` [ptxdist] [PATCH 1/2] mtd-utils: version bump 2.1.2 -> 2.1.3 Alexander Dahl
2021-10-07 10:18   ` [ptxdist] [APPLIED] " Michael Olbrich
2021-09-09 10:16 ` Alexander Dahl [this message]
2021-10-07 10:18   ` [ptxdist] [APPLIED] mtd-utils: Introduce systemd unit for ubihealthd Michael Olbrich

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=20210909101652.9288-3-ada@thorsis.com \
    --to=ada@thorsis.com \
    --cc=ptxdist@pengutronix.de \
    /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