package/openrc: add patch to support busybox version of sysctl
authorMichał Łyszczek <michal.lyszczek@bofc.pl>
Sun, 12 May 2019 19:55:46 +0000 (21:55 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sat, 18 May 2019 21:24:49 +0000 (23:24 +0200)
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@bofc.pl>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/openrc/0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch [new file with mode: 0644]

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 (file)
index 0000000..da8cf04
--- /dev/null
@@ -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@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
+