1From ec1a0c8fa2e7a7c6cf70f68bdabc07cbb1a567cf Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Micha=C5=82=20=C5=81yszczek?= <michal.lyszczek@bofc.pl>
3Date: Sun, 5 May 2019 23:43:40 +0200
4Subject: [PATCH] init.d/sysctl.in: add support for busybox sysctl
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Busybox version of sysctl does not support --system argument,
10and files need to be loaded one by one. This patch adds code
11to recognize busybox sysctl and execute proper function based
12on that.
13
14Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
15---
16 init.d/sysctl.in | 27 ++++++++++++++++++++++++++-
17 1 file changed, 26 insertions(+), 1 deletion(-)
18
19diff --git a/init.d/sysctl.in b/init.d/sysctl.in
20index e49f4db2..a705b3d4 100644
21--- a/init.d/sysctl.in
22+++ b/init.d/sysctl.in
23@@ -37,6 +37,23 @@ BSD_sysctl()
24 	return $retval
25 }
26
27+Busybox_sysctl()
28+{
29+	local quiet
30+	yesno $rc_verbose || quiet=-q
31+
32+	eindent
33+	for conf in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
34+		if [ -r "$conf" ]; then
35+			vebegin "applying $conf"
36+			sysctl $quiet -p "$conf" || retval=1
37+			veend $retval
38+		fi
39+	done
40+	eoutdent
41+	return $retval
42+}
43+
44 Linux_sysctl()
45 {
46 	local quiet
47@@ -52,7 +69,15 @@ start()
48 	ebegin "Configuring kernel parameters"
49 	case "$RC_UNAME" in
50 	*BSD|GNU) BSD_sysctl; rc=$? ;;
51-	Linux) Linux_sysctl; rc=$? ;;
52+	Linux)
53+		sysctl -h > /dev/null 2>&1
54+		if [ $? -ne 0 ]; then
55+			# busybox version of sysctl does not recognize -h option
56+			Busybox_sysctl
57+		else
58+			Linux_sysctl
59+		fi
60+		rc=$? ;;
61 	esac
62 	eend $rc "Unable to configure some kernel parameters"
63 }
64--
652.18.1
66
67