From 9c2358e4865327b76ee9273448e2cd78a18d76f3 Mon Sep 17 00:00:00 2001 From: Cameron Nemo Date: Thu, 3 Oct 2019 12:23:15 -0700 Subject: 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. --- core-services/08-sysctl.sh | 14 +++++++++----- 1 file 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 -- cgit 1.4.1