* [Buildroot] [PATCH 1/1] package/mosquitto: fix init script
@ 2025-03-31 17:12 Fiona Klute via buildroot
2025-04-21 21:34 ` Thomas Petazzoni via buildroot
2025-05-02 10:26 ` Arnout Vandecappelle via buildroot
0 siblings, 2 replies; 3+ messages in thread
From: Fiona Klute via buildroot @ 2025-03-31 17:12 UTC (permalink / raw)
To: buildroot; +Cc: Titouan Christophe, Fiona Klute
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
Restart would regularly fail because it did not wait for the old
process to be gone before starting the new one. Rewrite the script
according to current style to fix that, and add reload support (see
mosquitto docs for limitations of reload).
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
Policy question: Mosquitto supports configuring a PID file in the
configuration, but not on the command line. Using that would improve
the init script: We could let Mosquitto fork to background on its own,
instead of via start-stop-daemon. The default config would be easy to
adjust, but it would require people already using Mosquitto with
custom config files to adjust those to add the pid_file setting. Would
that be preferable for Buildroot? If yes, I can update the patch.
.checkpackageignore | 1 -
package/mosquitto/S50mosquitto | 79 +++++++++++++++++++++++++---------
2 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/.checkpackageignore b/.checkpackageignore
index 5350c6633a..2f9c65c8a3 100644
--- a/.checkpackageignore
+++ b/.checkpackageignore
@@ -823,7 +823,6 @@ package/mono-gtksharp3/0001-Fixes-MONO_PROFILE_ENTER_LEAVE-undeclared.patch lib_
package/mono-gtksharp3/0002-Mono-compilation-error-branch.patch lib_patch.Upstream
package/mono/0001-Fix-linkage-with-a-system-libatomic_ops-shared-library.patch lib_patch.Upstream
package/mono/0002-Ongoing-work-on-the-cmake-build.patch lib_patch.Upstream
-package/mosquitto/S50mosquitto Shellcheck lib_sysv.Indent lib_sysv.Variables
package/motion/S99motion Shellcheck lib_sysv.Indent lib_sysv.Variables
package/mpir/0001-mpn-arm-udiv.asm-workaround-binutils-bug-14887.patch lib_patch.Upstream
package/mpv/0001-fix-powerpc64-altivec.patch lib_patch.Upstream
diff --git a/package/mosquitto/S50mosquitto b/package/mosquitto/S50mosquitto
index 5241a071d7..89989179c1 100644
--- a/package/mosquitto/S50mosquitto
+++ b/package/mosquitto/S50mosquitto
@@ -1,35 +1,74 @@
#!/bin/sh
+DAEMON="mosquitto"
+PIDFILE="/var/run/$DAEMON.pid"
+MOSQUITTO_CONF="/etc/mosquitto/mosquitto.conf"
+
+[ -f "$MOSQUITTO_CONF" ] || exit 0
+
start() {
- printf "Starting mosquitto: "
- start-stop-daemon -S -q -m -b -p /var/run/mosquitto.pid \
- --exec /usr/sbin/mosquitto \
- -- -c /etc/mosquitto/mosquitto.conf
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ printf "Starting %s: " "$DAEMON"
+ start-stop-daemon --start --background --make-pidfile \
+ --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
+ -- -c "$MOSQUITTO_CONF"
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
}
+
stop() {
- printf "Stopping mosquitto: "
- start-stop-daemon -K -q -p /var/run/mosquitto.pid
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ printf "Stopping %s: " "$DAEMON"
+ start-stop-daemon --stop --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ return "$status"
+ fi
+ while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"; do
+ sleep 0.1
+ done
+ rm -f "$PIDFILE"
+ return "$status"
}
+
restart() {
stop
start
}
+reload() {
+ printf "Reloading %s config: " "$DAEMON"
+ start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
+ start)
+ start;;
+ stop)
+ stop;;
+ restart)
+ restart;;
+ reload)
+ reload;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
esac
exit $?
--
2.49.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] package/mosquitto: fix init script
2025-03-31 17:12 [Buildroot] [PATCH 1/1] package/mosquitto: fix init script Fiona Klute via buildroot
@ 2025-04-21 21:34 ` Thomas Petazzoni via buildroot
2025-05-02 10:26 ` Arnout Vandecappelle via buildroot
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2025-04-21 21:34 UTC (permalink / raw)
To: Fiona Klute via buildroot; +Cc: Fiona Klute, Titouan Christophe
Hello Fiona,
On Mon, 31 Mar 2025 19:12:12 +0200
Fiona Klute via buildroot <buildroot@buildroot.org> wrote:
> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>
> Restart would regularly fail because it did not wait for the old
> process to be gone before starting the new one. Rewrite the script
> according to current style to fix that, and add reload support (see
> mosquitto docs for limitations of reload).
>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Applied, thanks!
> Policy question: Mosquitto supports configuring a PID file in the
> configuration, but not on the command line. Using that would improve
> the init script: We could let Mosquitto fork to background on its own,
> instead of via start-stop-daemon. The default config would be easy to
> adjust, but it would require people already using Mosquitto with
> custom config files to adjust those to add the pid_file setting. Would
> that be preferable for Buildroot? If yes, I can update the patch.
To be honest, no strong opinion. What you did in the patch sounds good
to me, and the fact that the init script would have to rely on specific
settings in the configuration file looks less nice to me, so I applied
your patch as-is.
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] package/mosquitto: fix init script
2025-03-31 17:12 [Buildroot] [PATCH 1/1] package/mosquitto: fix init script Fiona Klute via buildroot
2025-04-21 21:34 ` Thomas Petazzoni via buildroot
@ 2025-05-02 10:26 ` Arnout Vandecappelle via buildroot
1 sibling, 0 replies; 3+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-02 10:26 UTC (permalink / raw)
To: Fiona Klute, buildroot; +Cc: Titouan Christophe
On 31/03/2025 19:12, Fiona Klute via buildroot wrote:
> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>
> Restart would regularly fail because it did not wait for the old
> process to be gone before starting the new one. Rewrite the script
> according to current style to fix that, and add reload support (see
> mosquitto docs for limitations of reload).
>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Applied to 2025.02.x, thanks.
Regards,
Arnout
> ---
>
> Policy question: Mosquitto supports configuring a PID file in the
> configuration, but not on the command line. Using that would improve
> the init script: We could let Mosquitto fork to background on its own,
> instead of via start-stop-daemon. The default config would be easy to
> adjust, but it would require people already using Mosquitto with
> custom config files to adjust those to add the pid_file setting. Would
> that be preferable for Buildroot? If yes, I can update the patch.
>
> .checkpackageignore | 1 -
> package/mosquitto/S50mosquitto | 79 +++++++++++++++++++++++++---------
> 2 files changed, 59 insertions(+), 21 deletions(-)
>
> diff --git a/.checkpackageignore b/.checkpackageignore
> index 5350c6633a..2f9c65c8a3 100644
> --- a/.checkpackageignore
> +++ b/.checkpackageignore
> @@ -823,7 +823,6 @@ package/mono-gtksharp3/0001-Fixes-MONO_PROFILE_ENTER_LEAVE-undeclared.patch lib_
> package/mono-gtksharp3/0002-Mono-compilation-error-branch.patch lib_patch.Upstream
> package/mono/0001-Fix-linkage-with-a-system-libatomic_ops-shared-library.patch lib_patch.Upstream
> package/mono/0002-Ongoing-work-on-the-cmake-build.patch lib_patch.Upstream
> -package/mosquitto/S50mosquitto Shellcheck lib_sysv.Indent lib_sysv.Variables
> package/motion/S99motion Shellcheck lib_sysv.Indent lib_sysv.Variables
> package/mpir/0001-mpn-arm-udiv.asm-workaround-binutils-bug-14887.patch lib_patch.Upstream
> package/mpv/0001-fix-powerpc64-altivec.patch lib_patch.Upstream
> diff --git a/package/mosquitto/S50mosquitto b/package/mosquitto/S50mosquitto
> index 5241a071d7..89989179c1 100644
> --- a/package/mosquitto/S50mosquitto
> +++ b/package/mosquitto/S50mosquitto
> @@ -1,35 +1,74 @@
> #!/bin/sh
>
> +DAEMON="mosquitto"
> +PIDFILE="/var/run/$DAEMON.pid"
> +MOSQUITTO_CONF="/etc/mosquitto/mosquitto.conf"
> +
> +[ -f "$MOSQUITTO_CONF" ] || exit 0
> +
> start() {
> - printf "Starting mosquitto: "
> - start-stop-daemon -S -q -m -b -p /var/run/mosquitto.pid \
> - --exec /usr/sbin/mosquitto \
> - -- -c /etc/mosquitto/mosquitto.conf
> - [ $? = 0 ] && echo "OK" || echo "FAIL"
> + printf "Starting %s: " "$DAEMON"
> + start-stop-daemon --start --background --make-pidfile \
> + --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
> + -- -c "$MOSQUITTO_CONF"
> + status=$?
> + if [ "$status" -eq 0 ]; then
> + echo "OK"
> + else
> + echo "FAIL"
> + fi
> + return "$status"
> }
> +
> stop() {
> - printf "Stopping mosquitto: "
> - start-stop-daemon -K -q -p /var/run/mosquitto.pid
> - [ $? = 0 ] && echo "OK" || echo "FAIL"
> + printf "Stopping %s: " "$DAEMON"
> + start-stop-daemon --stop --pidfile "$PIDFILE" \
> + --exec "/usr/sbin/$DAEMON"
> + status=$?
> + if [ "$status" -eq 0 ]; then
> + echo "OK"
> + else
> + echo "FAIL"
> + return "$status"
> + fi
> + while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
> + --exec "/usr/sbin/$DAEMON"; do
> + sleep 0.1
> + done
> + rm -f "$PIDFILE"
> + return "$status"
> }
> +
> restart() {
> stop
> start
> }
>
> +reload() {
> + printf "Reloading %s config: " "$DAEMON"
> + start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \
> + --exec "/usr/sbin/$DAEMON"
> + status=$?
> + if [ "$status" -eq 0 ]; then
> + echo "OK"
> + else
> + echo "FAIL"
> + fi
> + return "$status"
> +}
> +
> case "$1" in
> - start)
> - start
> - ;;
> - stop)
> - stop
> - ;;
> - restart|reload)
> - restart
> - ;;
> - *)
> - echo "Usage: $0 {start|stop|restart}"
> - exit 1
> + start)
> + start;;
> + stop)
> + stop;;
> + restart)
> + restart;;
> + reload)
> + reload;;
> + *)
> + echo "Usage: $0 {start|stop|restart|reload}"
> + exit 1
> esac
>
> exit $?
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-02 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 17:12 [Buildroot] [PATCH 1/1] package/mosquitto: fix init script Fiona Klute via buildroot
2025-04-21 21:34 ` Thomas Petazzoni via buildroot
2025-05-02 10:26 ` Arnout Vandecappelle via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox