* [ptxdist] [PATCH 0/2] mtd-utils: ubihealthd: Init script and help text @ 2023-06-12 6:38 Alexander Dahl 2023-06-12 6:38 ` [ptxdist] [PATCH 1/2] mtd-utils: Introduce bbinit startup for ubihealthd Alexander Dahl 2023-06-12 6:38 ` [ptxdist] [PATCH 2/2] mtd-utils: Add ubihealthd requirements to help text Alexander Dahl 0 siblings, 2 replies; 5+ messages in thread From: Alexander Dahl @ 2023-06-12 6:38 UTC (permalink / raw) To: ptxdist Hei hei, just made our targets using bbinit work with ubihealthd. (We already had support for systemd for other targets.) While at it, I found the help text is missing some requirements which can not easily be expressed through Kconfig. Greets Alex Alexander Dahl (2): mtd-utils: Introduce bbinit startup for ubihealthd mtd-utils: Add ubihealthd requirements to help text projectroot/etc/init.d/ubihealthd | 111 ++++++++++++++++++++++++++++++ rules/mtd-utils-bbinit.in | 9 +++ rules/mtd-utils.in | 6 ++ rules/mtd-utils.make | 8 +++ 4 files changed, 134 insertions(+) create mode 100755 projectroot/etc/init.d/ubihealthd create mode 100644 rules/mtd-utils-bbinit.in base-commit: 900bff9908170aad8a9b61b3e2c14b4734817d62 -- 2.30.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [ptxdist] [PATCH 1/2] mtd-utils: Introduce bbinit startup for ubihealthd 2023-06-12 6:38 [ptxdist] [PATCH 0/2] mtd-utils: ubihealthd: Init script and help text Alexander Dahl @ 2023-06-12 6:38 ` Alexander Dahl 2023-06-21 8:51 ` [ptxdist] [APPLIED] " Michael Olbrich 2023-06-12 6:38 ` [ptxdist] [PATCH 2/2] mtd-utils: Add ubihealthd requirements to help text Alexander Dahl 1 sibling, 1 reply; 5+ messages in thread From: Alexander Dahl @ 2023-06-12 6:38 UTC (permalink / raw) To: ptxdist We already introduced a systemd service unit with 434bd8a2cee9 ("mtd-utils: Introduce systemd unit for ubihealthd"), but it was not possible before to start the ubihealthd on bbinit based systems. This new init script does not allow to run multiple instances however and just starts one daemon for the default ubi device. The script is inspired and adapted from the one used for haveged. Signed-off-by: Alexander Dahl <ada@thorsis.com> --- projectroot/etc/init.d/ubihealthd | 111 ++++++++++++++++++++++++++++++ rules/mtd-utils-bbinit.in | 9 +++ rules/mtd-utils.in | 5 ++ rules/mtd-utils.make | 8 +++ 4 files changed, 133 insertions(+) create mode 100755 projectroot/etc/init.d/ubihealthd create mode 100644 rules/mtd-utils-bbinit.in diff --git a/projectroot/etc/init.d/ubihealthd b/projectroot/etc/init.d/ubihealthd new file mode 100755 index 000000000..62608cdff --- /dev/null +++ b/projectroot/etc/init.d/ubihealthd @@ -0,0 +1,111 @@ +#!/bin/sh + +PATH='/usr/sbin:/usr/bin' +DESC='ubihealthd UBI device PEB scan daemon' +NAME='ubihealthd' +DAEMON="/usr/sbin/$NAME" +DAEMON_ARGS='' +SCRIPTNAME="/etc/init.d/$NAME" + +# exit if binary is missing +[ -x "$DAEMON" ] || exit 0 + +is_running() { + start-stop-daemon -K --quiet --test --exec $DAEMON +} + +do_start() { + is_running && return 1 + start-stop-daemon -S --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2 +} + +do_stop() { + is_running || return 0 + start-stop-daemon -K --quiet --exec $DAEMON + RETVAL="$?" + + # wait up to 30 seconds until daemon stopped + for i in $(seq 30) + do + sleep 1 + echo -n '.' + if ! is_running + then + break + fi + done + + # see if it's still running + if is_running + then + start-stop-daemon -K --quiet --signal KILL --exec $DAEMON + + for i in $(seq 5) + do + sleep 1 + echo -n '.' + if ! is_running + then + break + fi + done + + if is_running + then + return 2 + fi + fi + + rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + echo -n "Starting $DESC ..." + do_start + case "$?" in + 0|1) echo " Done." ;; + 2) echo " Failed." ;; + esac + ;; + stop) + echo -n "Stopping $DESC ." + do_stop + case "$?" in + 0|1) echo " Done." ;; + 2) echo " Failed." ;; + esac + ;; + restart) + echo -n "Restarting $DESC .." + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) echo " Done." ;; + 1) echo " Failed." ;; # Old process still running + *) echo " Failed." ;; # Failed to start + esac + ;; + *) + echo " Failed." # Failed to stop + ;; + esac + ;; + status) + if is_running + then + echo "$NAME is running" + else + echo "$NAME is not running" + fi + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/rules/mtd-utils-bbinit.in b/rules/mtd-utils-bbinit.in new file mode 100644 index 000000000..e6b628938 --- /dev/null +++ b/rules/mtd-utils-bbinit.in @@ -0,0 +1,9 @@ +## SECTION=initmethod_bbinit + +config MTD_UTILS_UBIHEALTHD_BBINIT_LINK + string + depends on MTD_UTILS_UBIHEALTHD_STARTSCRIPT + prompt "ubihealthd" + default "S83ubihealthd" + +# vim: ft=kconfig noet tw=72 diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in index eaf073932..434d1e8fb 100644 --- a/rules/mtd-utils.in +++ b/rules/mtd-utils.in @@ -303,6 +303,11 @@ menuconfig MTD_UTILS_UBIHEALTHD if MTD_UTILS_UBIHEALTHD +config MTD_UTILS_UBIHEALTHD_STARTSCRIPT + bool + prompt "install /etc/init.d/ubihealthd" + depends on INITMETHOD_BBINIT + config MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT bool prompt "install systemd unit files" diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make index 0a181a879..659a0385b 100644 --- a/rules/mtd-utils.make +++ b/rules/mtd-utils.make @@ -205,6 +205,14 @@ endif ifdef PTXCONF_MTD_UTILS_UBIHEALTHD @$(call install_copy, mtd-utils, 0, 0, 0755, -, \ /usr/sbin/ubihealthd) +ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_STARTSCRIPT + @$(call install_alternative, mtd-utils, 0, 0, 0755, \ + /etc/init.d/ubihealthd) +ifneq ($(call remove_quotes,$(PTXCONF_MTD_UTILS_UBIHEALTHD_BBINIT_LINK)),) + @$(call install_link, mtd-utils, ../init.d/ubihealthd, \ + /etc/rc.d/$(PTXCONF_MTD_UTILS_UBIHEALTHD_BBINIT_LINK)) +endif +endif ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT @$(call install_alternative, mtd-utils, 0, 0, 0644, \ /usr/lib/systemd/system/ubihealthd@.service) -- 2.30.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ptxdist] [APPLIED] mtd-utils: Introduce bbinit startup for ubihealthd 2023-06-12 6:38 ` [ptxdist] [PATCH 1/2] mtd-utils: Introduce bbinit startup for ubihealthd Alexander Dahl @ 2023-06-21 8:51 ` Michael Olbrich 0 siblings, 0 replies; 5+ messages in thread From: Michael Olbrich @ 2023-06-21 8:51 UTC (permalink / raw) To: ptxdist; +Cc: Alexander Dahl Thanks, applied as 7b9d64648a001346a99f45900707c107c2a24084. Michael [sent from post-receive hook] On Wed, 21 Jun 2023 10:51:10 +0200, Alexander Dahl <ada@thorsis.com> wrote: > We already introduced a systemd service unit with 434bd8a2cee9 > ("mtd-utils: Introduce systemd unit for ubihealthd"), but it was not > possible before to start the ubihealthd on bbinit based systems. This > new init script does not allow to run multiple instances however and > just starts one daemon for the default ubi device. > > The script is inspired and adapted from the one used for haveged. > > Signed-off-by: Alexander Dahl <ada@thorsis.com> > Message-Id: <20230612063849.19499-2-ada@thorsis.com> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> > > diff --git a/projectroot/etc/init.d/ubihealthd b/projectroot/etc/init.d/ubihealthd > new file mode 100755 > index 000000000000..62608cdff282 > --- /dev/null > +++ b/projectroot/etc/init.d/ubihealthd > @@ -0,0 +1,111 @@ > +#!/bin/sh > + > +PATH='/usr/sbin:/usr/bin' > +DESC='ubihealthd UBI device PEB scan daemon' > +NAME='ubihealthd' > +DAEMON="/usr/sbin/$NAME" > +DAEMON_ARGS='' > +SCRIPTNAME="/etc/init.d/$NAME" > + > +# exit if binary is missing > +[ -x "$DAEMON" ] || exit 0 > + > +is_running() { > + start-stop-daemon -K --quiet --test --exec $DAEMON > +} > + > +do_start() { > + is_running && return 1 > + start-stop-daemon -S --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2 > +} > + > +do_stop() { > + is_running || return 0 > + start-stop-daemon -K --quiet --exec $DAEMON > + RETVAL="$?" > + > + # wait up to 30 seconds until daemon stopped > + for i in $(seq 30) > + do > + sleep 1 > + echo -n '.' > + if ! is_running > + then > + break > + fi > + done > + > + # see if it's still running > + if is_running > + then > + start-stop-daemon -K --quiet --signal KILL --exec $DAEMON > + > + for i in $(seq 5) > + do > + sleep 1 > + echo -n '.' > + if ! is_running > + then > + break > + fi > + done > + > + if is_running > + then > + return 2 > + fi > + fi > + > + rm -f $PIDFILE > + return "$RETVAL" > +} > + > +case "$1" in > + start) > + echo -n "Starting $DESC ..." > + do_start > + case "$?" in > + 0|1) echo " Done." ;; > + 2) echo " Failed." ;; > + esac > + ;; > + stop) > + echo -n "Stopping $DESC ." > + do_stop > + case "$?" in > + 0|1) echo " Done." ;; > + 2) echo " Failed." ;; > + esac > + ;; > + restart) > + echo -n "Restarting $DESC .." > + do_stop > + case "$?" in > + 0|1) > + do_start > + case "$?" in > + 0) echo " Done." ;; > + 1) echo " Failed." ;; # Old process still running > + *) echo " Failed." ;; # Failed to start > + esac > + ;; > + *) > + echo " Failed." # Failed to stop > + ;; > + esac > + ;; > + status) > + if is_running > + then > + echo "$NAME is running" > + else > + echo "$NAME is not running" > + fi > + ;; > + *) > + echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2 > + exit 3 > + ;; > +esac > + > +: > diff --git a/rules/mtd-utils-bbinit.in b/rules/mtd-utils-bbinit.in > new file mode 100644 > index 000000000000..e6b628938863 > --- /dev/null > +++ b/rules/mtd-utils-bbinit.in > @@ -0,0 +1,9 @@ > +## SECTION=initmethod_bbinit > + > +config MTD_UTILS_UBIHEALTHD_BBINIT_LINK > + string > + depends on MTD_UTILS_UBIHEALTHD_STARTSCRIPT > + prompt "ubihealthd" > + default "S83ubihealthd" > + > +# vim: ft=kconfig noet tw=72 > diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in > index eaf073932537..434d1e8fb99f 100644 > --- a/rules/mtd-utils.in > +++ b/rules/mtd-utils.in > @@ -303,6 +303,11 @@ menuconfig MTD_UTILS_UBIHEALTHD > > if MTD_UTILS_UBIHEALTHD > > +config MTD_UTILS_UBIHEALTHD_STARTSCRIPT > + bool > + prompt "install /etc/init.d/ubihealthd" > + depends on INITMETHOD_BBINIT > + > config MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT > bool > prompt "install systemd unit files" > diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make > index 0a181a879c0e..659a0385b783 100644 > --- a/rules/mtd-utils.make > +++ b/rules/mtd-utils.make > @@ -205,6 +205,14 @@ endif > ifdef PTXCONF_MTD_UTILS_UBIHEALTHD > @$(call install_copy, mtd-utils, 0, 0, 0755, -, \ > /usr/sbin/ubihealthd) > +ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_STARTSCRIPT > + @$(call install_alternative, mtd-utils, 0, 0, 0755, \ > + /etc/init.d/ubihealthd) > +ifneq ($(call remove_quotes,$(PTXCONF_MTD_UTILS_UBIHEALTHD_BBINIT_LINK)),) > + @$(call install_link, mtd-utils, ../init.d/ubihealthd, \ > + /etc/rc.d/$(PTXCONF_MTD_UTILS_UBIHEALTHD_BBINIT_LINK)) > +endif > +endif > ifdef PTXCONF_MTD_UTILS_UBIHEALTHD_SYSTEMD_UNIT > @$(call install_alternative, mtd-utils, 0, 0, 0644, \ > /usr/lib/systemd/system/ubihealthd@.service) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [ptxdist] [PATCH 2/2] mtd-utils: Add ubihealthd requirements to help text 2023-06-12 6:38 [ptxdist] [PATCH 0/2] mtd-utils: ubihealthd: Init script and help text Alexander Dahl 2023-06-12 6:38 ` [ptxdist] [PATCH 1/2] mtd-utils: Introduce bbinit startup for ubihealthd Alexander Dahl @ 2023-06-12 6:38 ` Alexander Dahl 2023-06-21 8:51 ` [ptxdist] [APPLIED] " Michael Olbrich 1 sibling, 1 reply; 5+ messages in thread From: Alexander Dahl @ 2023-06-12 6:38 UTC (permalink / raw) To: ptxdist Fixes: 7d4e5f3969df ("mtd-utils: version bump 2.1.1 -> 2.1.2") Signed-off-by: Alexander Dahl <ada@thorsis.com> --- rules/mtd-utils.in | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in index 434d1e8fb..8cc55caba 100644 --- a/rules/mtd-utils.in +++ b/rules/mtd-utils.in @@ -300,6 +300,7 @@ menuconfig MTD_UTILS_UBIHEALTHD help Daemon that randomly scans each PEB of a UBI device to ensure that filesystems with little reading do enough wear leveling. + Requires kernel >= 5.1 and glibc >= 2.25. if MTD_UTILS_UBIHEALTHD -- 2.30.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ptxdist] [APPLIED] mtd-utils: Add ubihealthd requirements to help text 2023-06-12 6:38 ` [ptxdist] [PATCH 2/2] mtd-utils: Add ubihealthd requirements to help text Alexander Dahl @ 2023-06-21 8:51 ` Michael Olbrich 0 siblings, 0 replies; 5+ messages in thread From: Michael Olbrich @ 2023-06-21 8:51 UTC (permalink / raw) To: ptxdist; +Cc: Alexander Dahl Thanks, applied as 784cc0ebfe3dc594159234c53b35e8e83bf0cdeb. Michael [sent from post-receive hook] On Wed, 21 Jun 2023 10:51:11 +0200, Alexander Dahl <ada@thorsis.com> wrote: > Fixes: 7d4e5f3969df ("mtd-utils: version bump 2.1.1 -> 2.1.2") > Signed-off-by: Alexander Dahl <ada@thorsis.com> > Message-Id: <20230612063849.19499-3-ada@thorsis.com> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> > > diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in > index 434d1e8fb99f..8cc55cabaac2 100644 > --- a/rules/mtd-utils.in > +++ b/rules/mtd-utils.in > @@ -300,6 +300,7 @@ menuconfig MTD_UTILS_UBIHEALTHD > help > Daemon that randomly scans each PEB of a UBI device to ensure that > filesystems with little reading do enough wear leveling. > + Requires kernel >= 5.1 and glibc >= 2.25. > > if MTD_UTILS_UBIHEALTHD > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-21 8:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-12 6:38 [ptxdist] [PATCH 0/2] mtd-utils: ubihealthd: Init script and help text Alexander Dahl 2023-06-12 6:38 ` [ptxdist] [PATCH 1/2] mtd-utils: Introduce bbinit startup for ubihealthd Alexander Dahl 2023-06-21 8:51 ` [ptxdist] [APPLIED] " Michael Olbrich 2023-06-12 6:38 ` [ptxdist] [PATCH 2/2] mtd-utils: Add ubihealthd requirements to help text Alexander Dahl 2023-06-21 8:51 ` [ptxdist] [APPLIED] " Michael Olbrich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox