* [Buildroot] [PATCH 0/6] Update init script style
@ 2024-07-12 9:47 Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 1/6] docs/manual: describe relying on default options Fiona Klute via buildroot
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
As discussed on the mailing list [1] init scripts may rely on the
default Buildroot options for Busybox and other base components being
enabled. This allows using long form options to start-stop-daemon in
init scripts for readability, among other things.
This series:
* Documents reliance on Buildroot defaults in the manual (patch 1)
* Updates the reference S01syslogd script to follow this and other
good practices (patch 2 & 3)
* Updates a few other scripts I've had to do with recently to follow
the same style.
[1] https://lore.kernel.org/buildroot/6d02d2d5-e71e-45b3-a447-e81521085e7a@mind.be/
Fiona Klute (WIWA) (6):
docs/manual: describe relying on default options
package/busybox: tidy up S01syslogd init script
docs/manual: include S01syslogd from source
package/openssh: tidy up init script
package/dnsmasq: tidy up init script
package/network-manager: rewrite init script
.checkpackageignore | 1 -
docs/manual/adding-packages-directory.adoc | 57 +-----------------
docs/manual/integration-principles.adoc | 20 +++++++
docs/manual/integration.adoc | 2 +
docs/manual/manual.mk | 5 ++
package/busybox/S01syslogd | 18 ++++--
package/dnsmasq/S80dnsmasq | 63 +++++++++++++-------
package/network-manager/S45NetworkManager | 68 ++++++++++++++++++++++
package/network-manager/S45network-manager | 41 -------------
package/network-manager/network-manager.mk | 2 +-
package/openssh/S50sshd | 12 ++--
11 files changed, 158 insertions(+), 131 deletions(-)
create mode 100644 docs/manual/integration-principles.adoc
create mode 100644 package/network-manager/S45NetworkManager
delete mode 100644 package/network-manager/S45network-manager
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/6] docs/manual: describe relying on default options
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script Fiona Klute via buildroot
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
People can assume that e.g. Busybox options enabled in the package are
enabled when writing code for Buildroot. Anyone who uses custom
configurations that disable default options needs to make sure
relevant scripts etc. still work for themselves.
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
docs/manual/integration-principles.adoc | 20 ++++++++++++++++++++
docs/manual/integration.adoc | 2 ++
2 files changed, 22 insertions(+)
create mode 100644 docs/manual/integration-principles.adoc
diff --git a/docs/manual/integration-principles.adoc b/docs/manual/integration-principles.adoc
new file mode 100644
index 0000000000..40c049f0d3
--- /dev/null
+++ b/docs/manual/integration-principles.adoc
@@ -0,0 +1,20 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+[[integration-principles]]
+=== Integration Principles
+
+Some foundational packages like Busybox and uClibc can be configured
+with or without certain features. When writing Buildroot code that
+uses such packages, contributors may assume that the options enabled
+in the Buildroot-provided configurations are enabled. For example,
++package/busybox/busybox.config+ sets
++CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y+, so init scripts
+meant for use with Busybox init may use +start-stop-daemon+ with long
+form options.
+
+People who use custom configurations that disable such default options
+are responsible for making sure that any relevant scripts/packages
+still work, and if not, adapting them accordingly. To follow the
+Busybox example above, disabling long form options will require
+replacing init scripts that use them (in an overlay).
diff --git a/docs/manual/integration.adoc b/docs/manual/integration.adoc
index 1626dd75dd..5f408dca29 100644
--- a/docs/manual/integration.adoc
+++ b/docs/manual/integration.adoc
@@ -9,6 +9,8 @@ level. Buildroot is highly configurable, almost everything discussed
here can be changed or overridden by xref:rootfs-custom[rootfs overlay
or custom skeleton] configuration.
+include::integration-principles.adoc[]
+
include::integration-systemd.adoc[]
include::integration-selinux-support.adoc[]
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 1/6] docs/manual: describe relying on default options Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
2024-07-12 11:07 ` Thomas Petazzoni via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 3/6] docs/manual: include S01syslogd from source Fiona Klute via buildroot
` (3 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
The manual refers to this script as a reference of how init scripts
should be written. The changes are:
* Use long form options for start-stop-daemon for clarity
* Use --exec on stop to ensure the right process gets stopped
* Avoid --quiet for clearer messages on failure
* Wait for the process to be gone during stop
* Avoid fixed wait between start and stop on restart
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
package/busybox/S01syslogd | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/package/busybox/S01syslogd b/package/busybox/S01syslogd
index 15006bc06f..5975fa7a80 100644
--- a/package/busybox/S01syslogd
+++ b/package/busybox/S01syslogd
@@ -9,11 +9,12 @@ SYSLOGD_ARGS=""
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
# BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line
-# and use "-m" to instruct start-stop-daemon to create one.
+# and use "--make-pidfile" to instruct start-stop-daemon to create one.
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
- start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
+ start-stop-daemon --start --background --make-pidfile \
+ --pidfile "$PIDFILE" --exec "/sbin/$DAEMON" \
-- -n $SYSLOGD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
@@ -26,20 +27,27 @@ start() {
stop() {
printf 'Stopping %s: ' "$DAEMON"
- start-stop-daemon -K -q -p "$PIDFILE"
+ start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/sbin/$DAEMON"
status=$?
if [ "$status" -eq 0 ]; then
- rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
+ return "$status"
fi
+ # Wait for process to be gone, because Busybox'
+ # start-stop-daemon does not support --retry (as of 1.36.1).
+ while true; do
+ pid="$( cat "${PIDFILE}" 2>/dev/null || true )"
+ { [ -n "${pid}" ] && [ -d "/proc/${pid}" ]; } || break
+ sleep 0.1
+ done
+ rm -f "$PIDFILE"
return "$status"
}
restart() {
stop
- sleep 1
start
}
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 3/6] docs/manual: include S01syslogd from source
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 1/6] docs/manual: describe relying on default options Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 4/6] package/openssh: tidy up init script Fiona Klute via buildroot
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
The manual describes package/busybox/S01syslogd as the reference of
how an init script should be written. Include it from source instead
of having a copy in the manual to ensure actual code and manual stay
in sync.
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
docs/manual/adding-packages-directory.adoc | 57 +---------------------
docs/manual/manual.mk | 5 ++
2 files changed, 7 insertions(+), 55 deletions(-)
diff --git a/docs/manual/adding-packages-directory.adoc b/docs/manual/adding-packages-directory.adoc
index 0b7221aae0..c61f78228b 100644
--- a/docs/manual/adding-packages-directory.adoc
+++ b/docs/manual/adding-packages-directory.adoc
@@ -578,62 +578,9 @@ not start before +S40network+. The scripts are started in alphabetical
order, so +S01syslogd+ starts before +S01watchdogd+, and +S02sysctl+
start thereafter.
+[source,sh]
------------------------------
-01: #!/bin/sh
-02:
-03: DAEMON="syslogd"
-04: PIDFILE="/var/run/$DAEMON.pid"
-05:
-06: SYSLOGD_ARGS=""
-07:
-08: # shellcheck source=/dev/null
-09: [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
-10:
-11: # BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line
-12: # and use "-m" to instruct start-stop-daemon to create one.
-13: start() {
-14: printf 'Starting %s: ' "$DAEMON"
-15: # shellcheck disable=SC2086 # we need the word splitting
-16: start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
-17: -- -n $SYSLOGD_ARGS
-18: status=$?
-19: if [ "$status" -eq 0 ]; then
-20: echo "OK"
-21: else
-22: echo "FAIL"
-23: fi
-24: return "$status"
-25: }
-26:
-27: stop() {
-28: printf 'Stopping %s: ' "$DAEMON"
-29: start-stop-daemon -K -q -p "$PIDFILE"
-30: status=$?
-31: if [ "$status" -eq 0 ]; then
-32: rm -f "$PIDFILE"
-33: echo "OK"
-34: else
-35: echo "FAIL"
-36: fi
-37: return "$status"
-38: }
-39:
-40: restart() {
-41: stop
-42: sleep 1
-43: start
-44: }
-45:
-46: case "$1" in
-47: start|stop|restart)
-48: "$1";;
-49: reload)
-50: # Restart, since there is no true "reload" feature.
-51: restart;;
-52: *)
-53: echo "Usage: $0 {start|stop|restart|reload}"
-54: exit 1
-55: esac
+include::S01syslogd[]
------------------------------
*Note:* programs that support reloading their configuration in some
diff --git a/docs/manual/manual.mk b/docs/manual/manual.mk
index e851a084ae..ca5a14f838 100644
--- a/docs/manual/manual.mk
+++ b/docs/manual/manual.mk
@@ -7,4 +7,9 @@
MANUAL_SOURCES = $(sort $(wildcard docs/manual/*.adoc) $(wildcard docs/images/*))
MANUAL_RESOURCES = $(TOPDIR)/docs/images
+define MANUAL_INIT_SCRIPT_REF
+ cp package/busybox/S01syslogd $(@D)/S01syslogd
+endef
+MANUAL_POST_RSYNC_HOOKS += MANUAL_INIT_SCRIPT_REF
+
$(eval $(call asciidoc-document))
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 4/6] package/openssh: tidy up init script
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
` (2 preceding siblings ...)
2024-07-12 9:47 ` [Buildroot] [PATCH 3/6] docs/manual: include S01syslogd from source Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 5/6] package/dnsmasq: " Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 6/6] package/network-manager: rewrite " Fiona Klute via buildroot
5 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
* Use long options for start-stop-daemon
* Avoid --quiet, except for reload where the "stopping" message could
be confusing
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
package/openssh/S50sshd | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/package/openssh/S50sshd b/package/openssh/S50sshd
index d16a7ad8fc..56db6ebff9 100644
--- a/package/openssh/S50sshd
+++ b/package/openssh/S50sshd
@@ -16,8 +16,8 @@ start() {
/usr/bin/ssh-keygen -A
printf "Starting %s: " "$DAEMON"
- start-stop-daemon -S -q -p "$PIDFILE" \
- -x "/usr/sbin/$DAEMON"
+ start-stop-daemon --start --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
@@ -29,8 +29,8 @@ start() {
stop() {
printf "Stopping sshd: "
- start-stop-daemon -K -q -p "$PIDFILE" \
- -x "/usr/sbin/$DAEMON"
+ start-stop-daemon --stop --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
@@ -51,8 +51,8 @@ restart() {
reload() {
printf "Reloading sshd config: "
- start-stop-daemon -K --signal HUP -q -p "$PIDFILE" \
- -x "/usr/sbin/$DAEMON"
+ start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 5/6] package/dnsmasq: tidy up init script
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
` (3 preceding siblings ...)
2024-07-12 9:47 ` [Buildroot] [PATCH 4/6] package/openssh: tidy up init script Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 6/6] package/network-manager: rewrite " Fiona Klute via buildroot
5 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
* Create start/stop/restart functions
* Use long start-stop-daemon options, avoid --quiet
* Return start-stop-daemon exit code from start/stop functions
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
package/dnsmasq/S80dnsmasq | 63 +++++++++++++++++++++++++-------------
1 file changed, 41 insertions(+), 22 deletions(-)
diff --git a/package/dnsmasq/S80dnsmasq b/package/dnsmasq/S80dnsmasq
index f1e1a68585..b876e3d411 100644
--- a/package/dnsmasq/S80dnsmasq
+++ b/package/dnsmasq/S80dnsmasq
@@ -5,30 +5,49 @@ PIDFILE="/var/run/$DAEMON.pid"
[ -f /etc/dnsmasq.conf ] || exit 0
+start() {
+ printf "Starting dnsmasq: "
+ start-stop-daemon --start --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON" \
+ -- --pid-file="$PIDFILE"
+ status=$?
+ [ "$status" -eq 0 ] && echo "OK" || echo "FAIL"
+ return "$status"
+}
+
+stop() {
+ printf "Stopping dnsmasq: "
+ start-stop-daemon --stop --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON"
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ return "$status"
+ fi
+ # wait for dnsmasq process to be gone
+ while true; do
+ pid="$( cat "${PIDFILE}" 2>/dev/null || true )"
+ { [ -n "${pid}" ] && [ -d "/proc/${pid}" ]; } || break
+ sleep 0.1
+ done
+ rm -f "$PIDFILE"
+ return "$status"
+}
+
+restart() {
+ stop
+ start
+}
+
case "$1" in
- start)
- printf "Starting dnsmasq: "
- start-stop-daemon -S -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- \
- --pid-file="$PIDFILE"
- # shellcheck disable=SC2181
- [ $? = 0 ] && echo "OK" || echo "FAIL"
- ;;
- stop)
- printf "Stopping dnsmasq: "
- start-stop-daemon -K -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON"
- # shellcheck disable=SC2181
- [ $? = 0 ] && echo "OK" || echo "FAIL"
- # wait for dnsmasq process to be gone
- while true; do
- pid="$( cat "${PIDFILE}" 2>/dev/null || true )"
- { [ -n "${pid}" ] && [ -d "/proc/${pid}" ]; } || break
- sleep 0.1
- done
- rm -f "$PIDFILE"
+ start|stop|restart)
+ "$1"
;;
- restart|reload)
- $0 stop
- $0 start
+ reload)
+ # Restart, since there is no true "reload" feature.
+ restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 6/6] package/network-manager: rewrite init script
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
` (4 preceding siblings ...)
2024-07-12 9:47 ` [Buildroot] [PATCH 5/6] package/dnsmasq: " Fiona Klute via buildroot
@ 2024-07-12 9:47 ` Fiona Klute via buildroot
5 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 9:47 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Fiona Klute (WIWA), Thomas Petazzoni
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
This brings the NetworkManager init script in line with the standard
Buildroot init script pattern, including the script name.
Reload using SIGHUP is also supported now, note that the
NetworkManager documentation cautions that not all parameters can be
changed at runtime (without a full restart).
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
.checkpackageignore | 1 -
package/network-manager/S45NetworkManager | 68 ++++++++++++++++++++++
package/network-manager/S45network-manager | 41 -------------
package/network-manager/network-manager.mk | 2 +-
4 files changed, 69 insertions(+), 43 deletions(-)
create mode 100644 package/network-manager/S45NetworkManager
delete mode 100644 package/network-manager/S45network-manager
diff --git a/.checkpackageignore b/.checkpackageignore
index 7cb4b98bfc..d39b5bdebd 100644
--- a/.checkpackageignore
+++ b/.checkpackageignore
@@ -1020,7 +1020,6 @@ package/netsurf/0002-do-not-cross-compile-nsgenbind.patch lib_patch.Upstream
package/netsurf/0003-fix-compilation-without-curl.patch lib_patch.Upstream
package/netsurf/0004-framebuffer-Fix-internal-font-generated-source-for-GCC-10.patch lib_patch.Upstream
package/nettle/0001-disable-testsuite-examples.patch lib_patch.Upstream
-package/network-manager/S45network-manager Shellcheck lib_sysv.ConsecutiveEmptyLines lib_sysv.EmptyLastLine lib_sysv.Variables
package/nfs-utils/S60nfs Shellcheck lib_sysv.ConsecutiveEmptyLines lib_sysv.Variables
package/nginx-modsecurity/0001-config-use-pkg-config.patch lib_patch.Upstream
package/nginx/0001-auto-type-sizeof-rework-autotest-to-be-cross-compila.patch lib_patch.Upstream
diff --git a/package/network-manager/S45NetworkManager b/package/network-manager/S45NetworkManager
new file mode 100644
index 0000000000..9f3398a347
--- /dev/null
+++ b/package/network-manager/S45NetworkManager
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+DAEMON="NetworkManager"
+PIDFILE="/var/run/$DAEMON.pid"
+
+# shellcheck source=/dev/null
+test -r "/etc/default/$DAEMON" && . "/etc/default/$DAEMON"
+
+start() {
+ printf 'Starting %s: ' "$DAEMON"
+ [ ! -d "/var/run/$DAEMON" ] && install -d "/var/run/$DAEMON"
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon --start --pidfile "$PIDFILE" \
+ --exec "/usr/sbin/$DAEMON" \
+ -- --pid-file="$PIDFILE" $NETWORKMANAGER_ARGS
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
+stop() {
+ 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
+ # NetworkManager deletes its PID file on exit, wait for it to
+ # be gone
+ while [ -f "$PIDFILE" ]; do
+ sleep 0.1
+ done
+ 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|stop|restart|reload)
+ "$1";;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac
diff --git a/package/network-manager/S45network-manager b/package/network-manager/S45network-manager
deleted file mode 100644
index bc775d3b20..0000000000
--- a/package/network-manager/S45network-manager
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-# Allow a few customizations from a config file
-test -r /etc/default/NetworkManager && . /etc/default/NetworkManager
-
-PID=`pidof NetworkManager`
-case "$1" in
- start)
- printf "Starting NetworkManager ... "
- [ ! -d /var/run/NetworkManager ] && install -d /var/run/NetworkManager
- if [ -z "$PID" ]; then
- /usr/sbin/NetworkManager $NETWORKMANAGER_ARGS
- fi
- if [ ! -z "$PID" -o $? -gt 0 ]; then
- echo "failed!"
- else
- echo "done."
- fi
- ;;
- stop)
- printf "Stopping NetworkManager ... "
- [ ! -z "$PID" ] && kill $PID > /dev/null 2>&1
- if [ $? -gt 0 ]; then
- echo "failed!"
- else
- echo "done."
- fi
- ;;
- restart)
- $0 stop
- sleep 1
- $0 start
- ;;
- *)
- echo "usage: $0 {start|stop|restart|sleep|wake}"
- ;;
-esac
-exit 0
-
-
-
diff --git a/package/network-manager/network-manager.mk b/package/network-manager/network-manager.mk
index cbd2ba8839..3937982c5f 100644
--- a/package/network-manager/network-manager.mk
+++ b/package/network-manager/network-manager.mk
@@ -163,7 +163,7 @@ NETWORK_MANAGER_CONF_OPTS += -Dnmcli=false
endif
define NETWORK_MANAGER_INSTALL_INIT_SYSV
- $(INSTALL) -m 0755 -D package/network-manager/S45network-manager $(TARGET_DIR)/etc/init.d/S45network-manager
+ $(INSTALL) -m 0755 -D package/network-manager/S45NetworkManager $(TARGET_DIR)/etc/init.d/S45NetworkManager
endef
define NETWORK_MANAGER_INSTALL_INIT_SYSTEMD
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script
2024-07-12 9:47 ` [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script Fiona Klute via buildroot
@ 2024-07-12 11:07 ` Thomas Petazzoni via buildroot
2024-07-12 11:34 ` Fiona Klute via buildroot
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-07-12 11:07 UTC (permalink / raw)
To: Fiona Klute via buildroot; +Cc: Bernd Kuhls, Fiona Klute
Hello Fiona,
Thanks for your work on this, much appreciated!
On Fri, 12 Jul 2024 11:47:13 +0200
Fiona Klute via buildroot <buildroot@buildroot.org> wrote:
> + # Wait for process to be gone, because Busybox'
> + # start-stop-daemon does not support --retry (as of 1.36.1).
> + while true; do
> + pid="$( cat "${PIDFILE}" 2>/dev/null || true )"
> + { [ -n "${pid}" ] && [ -d "/proc/${pid}" ]; } || break
> + sleep 0.1
I am not a big fan of this, and Arnout pointed out that Busybox
start-stop-daemon has the --status option:
-T,--status Check for the existence of a process, return exitcode (since version 1.16.1)
0 - program is running
1 - program is not running and the pid file exists
3 - program is not running
4 - can't determine program status
Could we use this instead of poking into /proc manually?
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] 9+ messages in thread
* Re: [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script
2024-07-12 11:07 ` Thomas Petazzoni via buildroot
@ 2024-07-12 11:34 ` Fiona Klute via buildroot
0 siblings, 0 replies; 9+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-12 11:34 UTC (permalink / raw)
To: Thomas Petazzoni, Fiona Klute via buildroot; +Cc: Bernd Kuhls
Am 12.07.24 um 13:07 schrieb Thomas Petazzoni:
> Hello Fiona,
>
> Thanks for your work on this, much appreciated!
Thank you!
> On Fri, 12 Jul 2024 11:47:13 +0200
> Fiona Klute via buildroot <buildroot@buildroot.org> wrote:
>
>> + # Wait for process to be gone, because Busybox'
>> + # start-stop-daemon does not support --retry (as of 1.36.1).
>> + while true; do
>> + pid="$( cat "${PIDFILE}" 2>/dev/null || true )"
>> + { [ -n "${pid}" ] && [ -d "/proc/${pid}" ]; } || break
>> + sleep 0.1
>
> I am not a big fan of this, and Arnout pointed out that Busybox
> start-stop-daemon has the --status option:
>
> -T,--status Check for the existence of a process, return exitcode (since version 1.16.1)
> 0 - program is running
> 1 - program is not running and the pid file exists
> 3 - program is not running
> 4 - can't determine program status
>
> Could we use this instead of poking into /proc manually?
Unfortunately not, because the Busybox version of start-stop-daemon
doesn't implement -T/--status. With the Debian version adding "--retry
TIMEOUT" to the stop command would be the elegant solution, but Busybox
silently ignores that one (I bumped into that before with Buildroot init
scripts).
Looking at the options that are supported, we might be able to use
--stop --test, it returns 1 if there is no matching process that could
be stopped.
That would make the loop something like (--quiet to not spam "stopping
..." messages):
while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE"
--exec "/sbin/$DAEMON"; do
sleep 0.1
done
I'll test that and respin if it works.
Best regards,
Fiona
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-12 11:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 9:47 [Buildroot] [PATCH 0/6] Update init script style Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 1/6] docs/manual: describe relying on default options Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 2/6] package/busybox: tidy up S01syslogd init script Fiona Klute via buildroot
2024-07-12 11:07 ` Thomas Petazzoni via buildroot
2024-07-12 11:34 ` Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 3/6] docs/manual: include S01syslogd from source Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 4/6] package/openssh: tidy up init script Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 5/6] package/dnsmasq: " Fiona Klute via buildroot
2024-07-12 9:47 ` [Buildroot] [PATCH 6/6] package/network-manager: rewrite " Fiona Klute via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox