0001-init.d-sysctl.in-add-support-for-busybox-sysctl.patch 1.6 KB

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