about summary refs log tree commit diff
path: root/core-services
diff options
context:
space:
mode:
authorCameron Nemo <cnemo@tutanota.com>2019-10-03 12:23:15 -0700
committerCameron Nemo <cnorman@cenic.org>2019-10-03 12:23:15 -0700
commit9c2358e4865327b76ee9273448e2cd78a18d76f3 (patch)
tree653f87057943a630406851322834a94ea3963953 /core-services
parentabd5e95bc3ec7cc4ef2c2bd7c7b04efefc0ec566 (diff)
downloadrunit-void-9c2358e4865327b76ee9273448e2cd78a18d76f3.tar.gz
runit-void-9c2358e4865327b76ee9273448e2cd78a18d76f3.tar.xz
runit-void-9c2358e4865327b76ee9273448e2cd78a18d76f3.zip
fix(sysctl): behave more like sysctl --system
Loading of sysctl.d directories should follow the same ordering and
overriding rules as xbps, modules-load, and most importantly,
`sysctl --system`.
This change ensures proper ordering of files loaded by building the
selected files then operating on them, and it allows for masking system
level configuration from /etc and even /run.
Diffstat (limited to 'core-services')
-rw-r--r--core-services/08-sysctl.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/core-services/08-sysctl.sh b/core-services/08-sysctl.sh
index 37d7b9f..3df5c5a 100644
--- a/core-services/08-sysctl.sh
+++ b/core-services/08-sysctl.sh
@@ -2,15 +2,19 @@
 
 if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
     msg "Loading sysctl(8) settings..."
+    mkdir -p /run/vsysctl.d
     for i in /run/sysctl.d/*.conf \
         /etc/sysctl.d/*.conf \
         /usr/local/lib/sysctl.d/*.conf \
-        /usr/lib/sysctl.d/*.conf \
-        /etc/sysctl.conf; do
+        /usr/lib/sysctl.d/*.conf; do
 
-        if [ -e "$i" ]; then
-            printf '* Applying %s ...\n' "$i"
-            sysctl -p "$i"
+        if [ -e "$i" ] && [ ! -e "/run/vsysctl.d/${i##*/}" ]; then
+            ln -s "$i" "/run/vsysctl.d/${i##*/}"
         fi
     done
+    for i in /run/vsysctl.d/*.conf; do
+        sysctl -p "$i"
+    done
+    rm -rf -- /run/vsysctl.d
+    sysctl -p /etc/sysctl.conf
 fi