hc
2024-07-02 39af2116d7581c9a12be9e73bb6bdc31496495ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From ec1a0c8fa2e7a7c6cf70f68bdabc07cbb1a567cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20=C5=81yszczek?= <michal.lyszczek@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@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