[Buildroot] [PATCH 09/13] package/openrc: add patch to support busybox version of sysctl

Michał Łyszczek michal.lyszczek at bofc.pl
Wed May 8 22:09:33 UTC 2019


Busybox version of sysctl does not support --system argument, and
files need to be loaded one by one. This patch adds code to sysctl
service in openrc to recognize busybox sysctl and execute proper
function based on that.

Signed-off-by: Michał Łyszczek <michal.lyszczek at bofc.pl>
---
 ...tl.in-add-support-for-busybox-sysctl.patch | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 package/openrc/0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch

diff --git a/package/openrc/0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch b/package/openrc/0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch
new file mode 100644
index 0000000000..da8cf042c6
--- /dev/null
+++ b/package/openrc/0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch
@@ -0,0 +1,66 @@
+From ec1a0c8fa2e7a7c6cf70f68bdabc07cbb1a567cf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20=C5=81yszczek?= <michal.lyszczek at bofc.pl>
+Date: Sun, 5 May 2019 23:43:40 +0200
+Subject: [PATCH] init.d/sysctl.in: add support for busybox sysctl
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Busybox version of sysctl does not support --system argument,
+and files need to be loaded one by one. This patch adds code
+to recognize busybox sysctl and execute proper function based
+on that.
+
+Signed-off-by: Michał Łyszczek <michal.lyszczek at bofc.pl>
+---
+ init.d/sysctl.in | 27 ++++++++++++++++++++++++++-
+ 1 file changed, 26 insertions(+), 1 deletion(-)
+
+diff --git a/init.d/sysctl.in b/init.d/sysctl.in
+index e49f4db2..a705b3d4 100644
+--- a/init.d/sysctl.in
++++ b/init.d/sysctl.in
+@@ -37,6 +37,23 @@ BSD_sysctl()
+ 	return $retval
+ }
+ 
++Busybox_sysctl()
++{
++	local quiet
++	yesno $rc_verbose || quiet=-q
++
++	eindent
++	for conf in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
++		if [ -r "$conf" ]; then
++			vebegin "applying $conf"
++			sysctl $quiet -p "$conf" || retval=1
++			veend $retval
++		fi
++	done
++	eoutdent
++	return $retval
++}
++
+ Linux_sysctl()
+ {
+ 	local quiet
+@@ -52,7 +69,15 @@ start()
+ 	ebegin "Configuring kernel parameters"
+ 	case "$RC_UNAME" in
+ 	*BSD|GNU) BSD_sysctl; rc=$? ;;
+-	Linux) Linux_sysctl; rc=$? ;;
++	Linux)
++		sysctl -h > /dev/null 2>&1
++		if [ $? -ne 0 ]; then
++			# busybox version of sysctl does not recognize -h option
++			Busybox_sysctl
++		else
++			Linux_sysctl
++		fi
++		rc=$? ;;
+ 	esac
+ 	eend $rc "Unable to configure some kernel parameters"
+ }
+-- 
+2.18.1
+
-- 
2.18.1



More information about the buildroot mailing list