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 <[email protected]>
---
 .../usr/lib/systemd/system/[email protected]      | 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/[email protected]

diff --git a/projectroot/usr/lib/systemd/system/[email protected] 
b/projectroot/usr/lib/systemd/system/[email protected]
new file mode 100644
index 000000000..f3f0ba25f
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/[email protected]
@@ -0,0 +1,13 @@
+# enable with `systemctl enable [email protected]`
+
+[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/[email protected])
+       @$(call install_link, mtd-utils, ../[email protected], \
+               
/usr/lib/systemd/system/multi-user.target.wants/[email protected])
+endif
 endif
 ifdef PTXCONF_MTD_UTILS_UBIMKVOL
        @$(call install_copy, mtd-utils, 0, 0, 0755, -, \
-- 
2.30.2


_______________________________________________
ptxdist mailing list
[email protected]
To unsubscribe, send a mail with subject "unsubscribe" to 
[email protected]

Reply via email to