sysctl: read settings from /etc/sysctl.d/*.conf
authorJohn Crispin <john@openwrt.org>
Tue, 7 Jul 2015 13:47:23 +0000 (13:47 +0000)
committerJohn Crispin <john@openwrt.org>
Tue, 7 Jul 2015 13:47:23 +0000 (13:47 +0000)
This changes makes it possible to store custom settings
in individual files inside the directory /etc/sysctl.d/.

Signed-off-by: Stefan Tomanek <stefan.tomanek+openwrt@wertarbyte.de>
SVN-Revision: 46239

package/base-files/Makefile
package/base-files/files/etc/hotplug.d/net/00-sysctl
package/base-files/files/etc/init.d/sysctl
package/base-files/files/etc/sysctl.d/local.conf [new file with mode: 0644]

index 0bba313702f0f9a3b42122b4b6beed929296d355..a5f15fa4e5eadbdee4391787ba566d717fc4217a 100644 (file)
@@ -55,6 +55,8 @@ define Package/base-files/conffiles
 /etc/config/
 /etc/dropbear/
 /etc/crontabs/
+/etc/sysctl.d/local.conf
+/etc/sysctl.d/
 $(call $(TARGET)/conffiles)
 endef
 
index 5d9da8ac060a90c9a0b89b5de1593a492414a14a..7a71652c44f8bd1fb9f2e5643e7baa5d5d76c369 100644 (file)
@@ -1,6 +1,9 @@
 #!/bin/sh
 
-if [ -f /etc/sysctl.conf ] && [ "$ACTION" = add ]; then
-       sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" /etc/sysctl.conf | \
-               sysctl -e -p - | logger -t sysctl
+if [ "$ACTION" = add ]; then
+       for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
+               [ ! -f "$CONF" ] && continue;
+               sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" "$CONF" | \
+                       sysctl -e -p - | logger -t sysctl
+       done
 fi
index 36e29eabcb8c4a4a42d2211cb2a3c14e8d179f87..2dfbaf7a6e473d81575c2692fc0f8e0e3d3d9952 100755 (executable)
@@ -3,5 +3,7 @@
 
 START=11
 start() {
-       [ -f /etc/sysctl.conf ] && sysctl -p -e >&-
+       for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
+               [ -f "$CONF" ] && sysctl -p "$CONF" -e >&-
+       done
 }
diff --git a/package/base-files/files/etc/sysctl.d/local.conf b/package/base-files/files/etc/sysctl.d/local.conf
new file mode 100644 (file)
index 0000000..891da73
--- /dev/null
@@ -0,0 +1 @@
+# local sysctl settings can be stored in this directory