[Buildroot] [git commit] package/mini-snmpd: add sysv init script

Julien Olivain via buildroot <[email protected]>
Newsgroups net.busybox.buildroot
Message-ID <[email protected]>
commit: https://gitlab.com/buildroot.org/buildroot/-/commit/54485e075d86a468f213d0ffcd339edc338df1dc
branch: https://gitlab.com/buildroot.org/buildroot/-/tree/master

A start script has been missing since the package was added, so the
daemon was not started automatically on sysv/busybox systems.

This also fixes a regression in systemd builds introduced in fccdc6bd,
when the package switched from local unit file to upstream.

Signed-off-by: Joachim Wiberg <[email protected]>
Signed-off-by: Julien Olivain <[email protected]>
---
 package/mini-snmpd/S60mini-snmpd | 52 ++++++++++++++++++++++++++++++++++++++++
 package/mini-snmpd/mini-snmpd    |  2 +-
 package/mini-snmpd/mini-snmpd.mk |  5 ++++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/package/mini-snmpd/S60mini-snmpd b/package/mini-snmpd/S60mini-snmpd
new file mode 100644
index 0000000000..e7c61d7a85
--- /dev/null
+++ b/package/mini-snmpd/S60mini-snmpd
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+DAEMON="mini-snmpd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+DAEMON_OPTS=""
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
+		--exec "/usr/sbin/$DAEMON" -- $DAEMON_OPTS
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon --stop --quiet --pidfile "$PIDFILE" \
+		--exec "/usr/sbin/$DAEMON"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+restart() {
+	stop
+	start
+}
+
+case "$1" in
+	start|stop|restart)
+		"$1";;
+	reload)
+		# Restart, since there is no true "reload" feature.
+		restart;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload}"
+		exit 1
+esac
diff --git a/package/mini-snmpd/mini-snmpd b/package/mini-snmpd/mini-snmpd
index 0ca9901d58..371f57f15f 100644
--- a/package/mini-snmpd/mini-snmpd
+++ b/package/mini-snmpd/mini-snmpd
@@ -1,2 +1,2 @@
 # Require client authentication, thus SNMP version 2c
-EXTRA_PARAMS=-a
+DAEMON_OPTS="-a -c public -s"
diff --git a/package/mini-snmpd/mini-snmpd.mk b/package/mini-snmpd/mini-snmpd.mk
index 89eca4ce79..99bef47477 100644
--- a/package/mini-snmpd/mini-snmpd.mk
+++ b/package/mini-snmpd/mini-snmpd.mk
@@ -19,4 +19,9 @@ endef
 
 MINI_SNMPD_POST_INSTALL_TARGET_HOOKS += MINI_SNMPD_INSTALL_ETC_DEFAULT
 
+define MINI_SNMPD_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 package/mini-snmpd/S60mini-snmpd \
+		$(TARGET_DIR)/etc/init.d/S60mini-snmpd
+endef
+
 $(eval $(autotools-package))
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.