* [Buildroot] [PATCH v3 1/2] package/procps-ng: add init script for sysctl
@ 2019-05-01 23:11 unixmania at gmail.com
2019-05-01 23:11 ` [Buildroot] [PATCH v3 2/2] package/busybox: " unixmania at gmail.com
2019-08-03 16:47 ` [Buildroot] [PATCH v3 1/2] package/procps-ng: " Peter Korsgaard
0 siblings, 2 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2019-05-01 23:11 UTC (permalink / raw)
To: buildroot
From: Carlos Santos <unixmania@gmail.com>
Add a simple init script that invokes sysctl early in the initialization
process to configure kernel parameters. This is already performed by
systemd (systemd-sysctl) but there is no sysvinit/busybox counterpart.
Files are read from directories in the following list in the given order
from top to bottom:
/run/sysctl.d/*.conf
/etc/sysctl.d/*.conf
/usr/local/lib/sysctl.d/*.conf
/usr/lib/sysctl.d/*.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
Changes v2->v3:
- Update SOB, since I don't work for DATACOM anymore.
Changes v1->v2:
- The "--system" option activates "--ignore", which is bad because
invalid variable settings in the configuration files will not be
reported on the system log. Use some scripting to mimic the --system
behavior but still reporting errors.
- Redirect sysctl's standard output to syslog with facility.level
"kern.info" and standard error to syslog with facility.level
"kern.err".
- Do not pass "--quiet" to sysctl, since we wanto to see the results.
- Use "Running" and "Rerunning" instead of "Starting", since we do not
really start anything, just run a program.
- Do nothing on "stop", since ther is no running daemon to stop.
---
package/procps-ng/S02sysctl | 64 ++++++++++++++++++++++++++++++++++
package/procps-ng/procps-ng.mk | 5 +++
2 files changed, 69 insertions(+)
create mode 100644 package/procps-ng/S02sysctl
---
package/procps-ng/S02sysctl | 64 ++++++++++++++++++++++++++++++++++
package/procps-ng/procps-ng.mk | 5 +++
2 files changed, 69 insertions(+)
create mode 100644 package/procps-ng/S02sysctl
diff --git a/package/procps-ng/S02sysctl b/package/procps-ng/S02sysctl
new file mode 100644
index 0000000000..3a58578de4
--- /dev/null
+++ b/package/procps-ng/S02sysctl
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+PROGRAM="sysctl"
+
+SYSCTL_ARGS=""
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM"
+
+# Files are read from directories in the SYSCTL_SOURCES list, in the given
+# order. A file may be used more than once, since there can be multiple
+# symlinks to it. No attempt is made to prevent this.
+SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf"
+
+# The "--system" option activates "--ignore", which is bad because invalid
+# variable settings in the configuration files will not be reported on the
+# system log. Use some scripting to mimic the --system behavior but still
+# reporting errors. Users not interested on error report can put "-e" in
+# SYSCTL_ARGS.
+#
+# The file redirections do the following:
+#
+# - stdout is redirected to syslog with facility.level "kern.info"
+# - stderr is redirected to syslog with facility.level "kern.err"
+# - file dscriptor 4 is used to pass the result to the "start" function.
+#
+run_program() {
+ # shellcheck disable=SC2086 # we need the word splitting
+ find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \
+ xargs -0 -r -n 1 readlink -f | {
+ prog_status="OK"
+ while :; do
+ read -r file
+ if [ -z "$file" ]; then
+ echo "$prog_status" >&4
+ break
+ fi
+ echo "* Applying $file ..."
+ /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+ done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
+ } 3>&1 | /usr/bin/logger -t sysctl -p kern.info
+}
+
+start() {
+ printf '%s %s: ' "$1" "$PROGRAM"
+ status=$(run_program 4>&1)
+ echo "$status"
+ if [ "$status" = "OK" ]; then
+ return 0
+ fi
+ return 1
+}
+
+case "$1" in
+ start)
+ start "Running";;
+ restart|reload)
+ start "Rerunning";;
+ stop)
+ :;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac
diff --git a/package/procps-ng/procps-ng.mk b/package/procps-ng/procps-ng.mk
index 03b74784d2..6a41e9b322 100644
--- a/package/procps-ng/procps-ng.mk
+++ b/package/procps-ng/procps-ng.mk
@@ -44,4 +44,9 @@ ifeq ($(BR2_STATIC_LIBS),y)
PROCPS_NG_CONF_OPTS += --disable-numa
endif
+define PROCPS_NG_INSTALL_INIT_SYSV
+ $(INSTALL) -D -m 755 package/procps-ng/S02sysctl \
+ $(TARGET_DIR)/etc/init.d/S02sysctl
+endef
+
$(eval $(autotools-package))
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v3 2/2] package/busybox: add init script for sysctl
2019-05-01 23:11 [Buildroot] [PATCH v3 1/2] package/procps-ng: add init script for sysctl unixmania at gmail.com
@ 2019-05-01 23:11 ` unixmania at gmail.com
2019-05-02 2:07 ` Matthew Weber
2019-08-03 16:45 ` Peter Korsgaard
2019-08-03 16:47 ` [Buildroot] [PATCH v3 1/2] package/procps-ng: " Peter Korsgaard
1 sibling, 2 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2019-05-01 23:11 UTC (permalink / raw)
To: buildroot
From: Carlos Santos <unixmania@gmail.com>
Add a simple init script that invokes sysctl early in the initialization
process to configure kernel parameters. This is already performed by
systemd (systemd-sysctl) but there is no sysvinit/busybox counterpart.
Files are read from directories in the following list in the given order
from top to bottom:
/run/sysctl.d/*.conf
/etc/sysctl.d/*.conf
/usr/local/lib/sysctl.d/*.conf
/usr/lib/sysctl.d/*.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf
A file may be used more than once, since there can be multiple symlinks
to it. No attempt is made to prevent this.
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
Changes v2->v3:
- Update SOB, since I don't work for DATACOM anymore.
Changes v1->v2:
- Use a while loop to process all files.
- Redirect sysctl's standard output to syslog with facility.level
"kern.info" and standard error to syslog with facility.level
"kern.err".
- Do not pass "-q" to sysctl, since we wanto to see the results.
- Use "Running" and "Rerunning" instead of "Starting", since we do not
really start anything, just run a program.
- Do nothing on "stop", since ther is no running daemon to stop.
---
package/busybox/S02sysctl | 66 ++++++++++++++++++++++++++++++++++++++
package/busybox/busybox.mk | 12 +++++++
2 files changed, 78 insertions(+)
create mode 100644 package/busybox/S02sysctl
---
package/busybox/S02sysctl | 66 ++++++++++++++++++++++++++++++++++++++
package/busybox/busybox.mk | 12 +++++++
2 files changed, 78 insertions(+)
create mode 100644 package/busybox/S02sysctl
diff --git a/package/busybox/S02sysctl b/package/busybox/S02sysctl
new file mode 100644
index 0000000000..6bb2fa165e
--- /dev/null
+++ b/package/busybox/S02sysctl
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+PROGRAM="sysctl"
+
+SYSCTL_ARGS=""
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM"
+
+# Files are read from directories in the SYSCTL_SOURCES list, in the given
+# order. A file may be used more than once, since there can be multiple
+# symlinks to it. No attempt is made to prevent this.
+SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf"
+
+# Use some scripting to mimic the --system option of the sysctl provided by
+# procps-ng but still reporting errors. Users not interested on error report
+# can put "-e" in SYSCTL_ARGS.
+#
+# The file redirections do the following:
+#
+# - stdout is redirected to syslog with facility.level "kern.info"
+# - stderr is redirected to syslog with facility.level "kern.err"
+# - file dscriptor 4 is used to pass the result to the "start" function.
+#
+# Testing the sysctl exit code is fruitless, as at the moment, since it ends
+# with status zero even if errors happen. Hopefully this will be fixed in a
+# future version of Busybox.
+#
+run_program() {
+ # shellcheck disable=SC2086 # we need the word splitting
+ find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \
+ xargs -0 -r -n 1 readlink -f | {
+ prog_status="OK"
+ while :; do
+ read -r file
+ if [ -z "$file" ]; then
+ echo "$prog_status" >&4
+ break
+ fi
+ echo "* Applying $file ..."
+ /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+ done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
+ } 3>&1 | /usr/bin/logger -t sysctl -p kern.info
+}
+
+start() {
+ printf '%s %s: ' "$1" "$PROGRAM"
+ status=$(run_program 4>&1)
+ echo "$status"
+ if [ "$status" = "OK" ]; then
+ return 0
+ fi
+ return 1
+}
+
+case "$1" in
+ start)
+ start "Running";;
+ restart|reload)
+ start "Rerunning";;
+ stop)
+ :;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 67b91500e9..416b6f9bae 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -259,6 +259,17 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT
endef
endif
+# Only install our sysctl scripts if no other package does it.
+ifeq ($(BR2_PACKAGE_PROCPS_NG),)
+define BUSYBOX_INSTALL_SYSCTL_SCRIPT
+ if grep -q CONFIG_BB_SYSCTL=y $(@D)/.config; \
+ then \
+ $(INSTALL) -m 0755 -D package/busybox/S02sysctl \
+ $(TARGET_DIR)/etc/init.d/S02sysctl ; \
+ fi
+endef
+endif
+
ifeq ($(BR2_INIT_BUSYBOX),y)
define BUSYBOX_INSTALL_INITTAB
$(INSTALL) -D -m 0644 package/busybox/inittab $(TARGET_DIR)/etc/inittab
@@ -340,6 +351,7 @@ define BUSYBOX_INSTALL_INIT_SYSV
$(BUSYBOX_INSTALL_MDEV_SCRIPT)
$(BUSYBOX_INSTALL_LOGGING_SCRIPT)
$(BUSYBOX_INSTALL_WATCHDOG_SCRIPT)
+ $(BUSYBOX_INSTALL_SYSCTL_SCRIPT)
$(BUSYBOX_INSTALL_TELNET_SCRIPT)
$(BUSYBOX_INSTALL_INDIVIDUAL_BINARIES)
endef
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v3 2/2] package/busybox: add init script for sysctl
2019-05-01 23:11 ` [Buildroot] [PATCH v3 2/2] package/busybox: " unixmania at gmail.com
@ 2019-05-02 2:07 ` Matthew Weber
2019-05-02 2:41 ` Carlos A. M. dos Santos
2019-08-03 16:45 ` Peter Korsgaard
1 sibling, 1 reply; 6+ messages in thread
From: Matthew Weber @ 2019-05-02 2:07 UTC (permalink / raw)
To: buildroot
Carlos,
On Wed, May 1, 2019 at 6:11 PM <unixmania@gmail.com> wrote:
>
> From: Carlos Santos <unixmania@gmail.com>
>
> Add a simple init script that invokes sysctl early in the initialization
> process to configure kernel parameters. This is already performed by
> systemd (systemd-sysctl) but there is no sysvinit/busybox counterpart.
>
> Files are read from directories in the following list in the given order
> from top to bottom:
>
> /run/sysctl.d/*.conf
> /etc/sysctl.d/*.conf
> /usr/local/lib/sysctl.d/*.conf
> /usr/lib/sysctl.d/*.conf
> /lib/sysctl.d/*.conf
> /etc/sysctl.conf
>
> A file may be used more than once, since there can be multiple symlinks
> to it. No attempt is made to prevent this.
>
> Signed-off-by: Carlos Santos <unixmania@gmail.com>
Reviewed-by: Matthew Weber <matthew.weber@rockwellcollins.com>
> ---
> Changes v2->v3:
> - Update SOB, since I don't work for DATACOM anymore.
> Changes v1->v2:
> - Use a while loop to process all files.
> - Redirect sysctl's standard output to syslog with facility.level
> "kern.info" and standard error to syslog with facility.level
> "kern.err".
> - Do not pass "-q" to sysctl, since we wanto to see the results.
> - Use "Running" and "Rerunning" instead of "Starting", since we do not
> really start anything, just run a program.
> - Do nothing on "stop", since ther is no running daemon to stop.
> ---
> package/busybox/S02sysctl | 66 ++++++++++++++++++++++++++++++++++++++
> package/busybox/busybox.mk | 12 +++++++
> 2 files changed, 78 insertions(+)
> create mode 100644 package/busybox/S02sysctl
> ---
> package/busybox/S02sysctl | 66 ++++++++++++++++++++++++++++++++++++++
> package/busybox/busybox.mk | 12 +++++++
> 2 files changed, 78 insertions(+)
> create mode 100644 package/busybox/S02sysctl
>
> diff --git a/package/busybox/S02sysctl b/package/busybox/S02sysctl
> new file mode 100644
> index 0000000000..6bb2fa165e
> --- /dev/null
> +++ b/package/busybox/S02sysctl
> @@ -0,0 +1,66 @@
> +#!/bin/sh
> +
> +PROGRAM="sysctl"
> +
> +SYSCTL_ARGS=""
> +
> +# shellcheck source=/dev/null
> +[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM"
> +
> +# Files are read from directories in the SYSCTL_SOURCES list, in the given
> +# order. A file may be used more than once, since there can be multiple
> +# symlinks to it. No attempt is made to prevent this.
> +SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf"
> +
> +# Use some scripting to mimic the --system option of the sysctl provided by
> +# procps-ng but still reporting errors. Users not interested on error report
> +# can put "-e" in SYSCTL_ARGS.
> +#
> +# The file redirections do the following:
> +#
> +# - stdout is redirected to syslog with facility.level "kern.info"
> +# - stderr is redirected to syslog with facility.level "kern.err"
> +# - file dscriptor 4 is used to pass the result to the "start" function.
> +#
> +# Testing the sysctl exit code is fruitless, as at the moment, since it ends
> +# with status zero even if errors happen. Hopefully this will be fixed in a
> +# future version of Busybox.
> +#
> +run_program() {
> + # shellcheck disable=SC2086 # we need the word splitting
> + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \
> + xargs -0 -r -n 1 readlink -f | {
> + prog_status="OK"
> + while :; do
> + read -r file
> + if [ -z "$file" ]; then
> + echo "$prog_status" >&4
> + break
> + fi
> + echo "* Applying $file ..."
> + /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
> + done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
> + } 3>&1 | /usr/bin/logger -t sysctl -p kern.info
Should the utilities used above be enabled automatically in the
busybox config when this script is installed? I.e. add .config fixups
in the busybox.mk
> +}
> +
> +start() {
> + printf '%s %s: ' "$1" "$PROGRAM"
> + status=$(run_program 4>&1)
> + echo "$status"
> + if [ "$status" = "OK" ]; then
> + return 0
> + fi
> + return 1
> +}
> +
> +case "$1" in
> + start)
> + start "Running";;
> + restart|reload)
> + start "Rerunning";;
> + stop)
> + :;;
> + *)
> + echo "Usage: $0 {start|stop|restart|reload}"
> + exit 1
> +esac
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index 67b91500e9..416b6f9bae 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -259,6 +259,17 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT
> endef
> endif
>
> +# Only install our sysctl scripts if no other package does it.
> +ifeq ($(BR2_PACKAGE_PROCPS_NG),)
> +define BUSYBOX_INSTALL_SYSCTL_SCRIPT
> + if grep -q CONFIG_BB_SYSCTL=y $(@D)/.config; \
> + then \
> + $(INSTALL) -m 0755 -D package/busybox/S02sysctl \
> + $(TARGET_DIR)/etc/init.d/S02sysctl ; \
> + fi
> +endef
> +endif
> +
[snip]
Matt
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v3 2/2] package/busybox: add init script for sysctl
2019-05-02 2:07 ` Matthew Weber
@ 2019-05-02 2:41 ` Carlos A. M. dos Santos
0 siblings, 0 replies; 6+ messages in thread
From: Carlos A. M. dos Santos @ 2019-05-02 2:41 UTC (permalink / raw)
To: buildroot
On Wed, May 1, 2019 at 11:07 PM Matthew Weber <matthew.weber@collins.com> wrote:
>
> Carlos,
>
> Should the utilities used above be enabled automatically in the
> busybox config when this script is installed? I.e. add .config fixups
> in the busybox.mk
It does not seem to be necessary, at the moment. The utilities are
already selected in the default busybox configuration.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v3 2/2] package/busybox: add init script for sysctl
2019-05-01 23:11 ` [Buildroot] [PATCH v3 2/2] package/busybox: " unixmania at gmail.com
2019-05-02 2:07 ` Matthew Weber
@ 2019-08-03 16:45 ` Peter Korsgaard
1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2019-08-03 16:45 UTC (permalink / raw)
To: buildroot
>>>>> "unixmania" == unixmania <unixmania@gmail.com> writes:
Hi,
> From: Carlos Santos <unixmania@gmail.com>
> Add a simple init script that invokes sysctl early in the initialization
> process to configure kernel parameters. This is already performed by
> systemd (systemd-sysctl) but there is no sysvinit/busybox counterpart.
> Files are read from directories in the following list in the given order
> from top to bottom:
> /run/sysctl.d/*.conf
> /etc/sysctl.d/*.conf
> /usr/local/lib/sysctl.d/*.conf
> /usr/lib/sysctl.d/*.conf
> /lib/sysctl.d/*.conf
> /etc/sysctl.conf
> A file may be used more than once, since there can be multiple symlinks
> to it. No attempt is made to prevent this.
> Signed-off-by: Carlos Santos <unixmania@gmail.com>
> ---
> Changes v2->v3:
> - Update SOB, since I don't work for DATACOM anymore.
> Changes v1->v2:
> - Use a while loop to process all files.
> - Redirect sysctl's standard output to syslog with facility.level
> "kern.info" and standard error to syslog with facility.level
> "kern.err".
> - Do not pass "-q" to sysctl, since we wanto to see the results.
> - Use "Running" and "Rerunning" instead of "Starting", since we do not
> really start anything, just run a program.
> - Do nothing on "stop", since ther is no running daemon to stop.
Committed, thanks. Sorry for the delay.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v3 1/2] package/procps-ng: add init script for sysctl
2019-05-01 23:11 [Buildroot] [PATCH v3 1/2] package/procps-ng: add init script for sysctl unixmania at gmail.com
2019-05-01 23:11 ` [Buildroot] [PATCH v3 2/2] package/busybox: " unixmania at gmail.com
@ 2019-08-03 16:47 ` Peter Korsgaard
1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2019-08-03 16:47 UTC (permalink / raw)
To: buildroot
>>>>> "unixmania" == unixmania <unixmania@gmail.com> writes:
> From: Carlos Santos <unixmania@gmail.com>
> Add a simple init script that invokes sysctl early in the initialization
> process to configure kernel parameters. This is already performed by
> systemd (systemd-sysctl) but there is no sysvinit/busybox counterpart.
> Files are read from directories in the following list in the given order
> from top to bottom:
> /run/sysctl.d/*.conf
> /etc/sysctl.d/*.conf
> /usr/local/lib/sysctl.d/*.conf
> /usr/lib/sysctl.d/*.conf
> /lib/sysctl.d/*.conf
> /etc/sysctl.conf
> Signed-off-by: Carlos Santos <unixmania@gmail.com>
> ---
> Changes v2->v3:
> - Update SOB, since I don't work for DATACOM anymore.
> Changes v1->v2:
> - The "--system" option activates "--ignore", which is bad because
> invalid variable settings in the configuration files will not be
> reported on the system log. Use some scripting to mimic the --system
> behavior but still reporting errors.
> - Redirect sysctl's standard output to syslog with facility.level
> "kern.info" and standard error to syslog with facility.level
> "kern.err".
> - Do not pass "--quiet" to sysctl, since we wanto to see the results.
> - Use "Running" and "Rerunning" instead of "Starting", since we do not
> really start anything, just run a program.
> - Do nothing on "stop", since ther is no running daemon to stop.
Committed, thanks.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-03 16:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 23:11 [Buildroot] [PATCH v3 1/2] package/procps-ng: add init script for sysctl unixmania at gmail.com
2019-05-01 23:11 ` [Buildroot] [PATCH v3 2/2] package/busybox: " unixmania at gmail.com
2019-05-02 2:07 ` Matthew Weber
2019-05-02 2:41 ` Carlos A. M. dos Santos
2019-08-03 16:45 ` Peter Korsgaard
2019-08-03 16:47 ` [Buildroot] [PATCH v3 1/2] package/procps-ng: " Peter Korsgaard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.