]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
add apply_sysctl() to load sysctl parameters
authorElan Ruusamäe <glen@pld-linux.org>
Wed, 17 Jul 2013 20:52:15 +0000 (20:52 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Wed, 17 Jul 2013 20:52:15 +0000 (20:52 +0000)
uses systemd-sysctl(8) to load, if present, otherwise
loads files in same way as systemd-sysctl(8):
/usr/lib/sysctl.d, /run/sysctl.d, /etc/sysctl.d, /etc/sysctl.conf
where matching files from .d files are not loaded

see sysctl.d(5) for description

svn-id: @12700

lib/functions
rc.d/init.d/network
rc.d/rc.sysinit
sysctl.conf

index 4658d6f08a178fc51c35b1573d5b9972b626a1bf..ef420857d6203ef638e4104dfc18b73df32bd088 100644 (file)
@@ -169,6 +169,29 @@ strstr() {
        return 0
 }
 
+# Apply sysctl settings, including files in /etc/sysctl.d
+apply_sysctl() {
+       if [ -x /lib/systemd/systemd-sysctl ]; then
+               /lib/systemd/systemd-sysctl
+               return
+       fi
+
+       local file
+       for file in /usr/lib/sysctl.d/*.conf; do
+               [ -f /run/sysctl.d/${file##*/} ] && continue
+               [ -f /etc/sysctl.d/${file##*/} ] && continue
+               test -f "$file" && sysctl -q -e -p "$file"
+       done
+       for file in /run/sysctl.d/*.conf; do
+               [ -f /etc/sysctl.d/${file##*/} ] && continue
+               test -f "$file" && sysctl -q -e -p "$file"
+       done
+       for file in /etc/sysctl.d/*.conf; do
+               test -f "$file" && sysctl -q -e -p "$file"
+       done
+       sysctl -q -e -p /etc/sysctl.conf
+}
+
 if is_yes "$FASTRC" || is_yes "$IN_SHUTDOWN"; then
        RC_LOGGING=no
 fi
index d01c45115045905a50ae45f1bb82437965a56e1a..d481a82c6e54cb0c468b8ac815685d204fd3790b 100755 (executable)
@@ -47,6 +47,9 @@ network_init() {
        # Modprobe needed devices
        modprobe_net
 
+       # load sysctl params
+       apply_sysctl
+
        # Setup interfaces names
        if ! is_empty_file /etc/mactab && [ -x /sbin/nameif ]; then
                run_cmd "Setting interfaces names (nameif)" /sbin/nameif
@@ -87,6 +90,9 @@ network_init() {
 }
 
 network_postinit() {
+       # Run this again to catch any interface-specific actions
+       apply_sysctl
+
        # Set static RARP table
        static_rarp
 
index e321c9a87cf92bcc318ab2ee4d5f4956089098bf..8f2a28e60bc66f284d3b4d0a658cfdd534ec0e4b 100755 (executable)
@@ -366,7 +366,7 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # Early sysctls
-       sysctl -q -e -p /etc/sysctl.conf
+       apply_sysctl
 
        # sysfs is also needed before any other things (under kernel > 2.5)
        if ! is_fsmounted sysfs /sys; then
@@ -456,9 +456,8 @@ if ! is_yes "$VSERVER"; then
                /sbin/blogd
        fi
 
-       # Configure Linux kernel (initial configuration, some required modules still
-       # may be missing).
-       sysctl -q -e -p /etc/sysctl.conf
+       # Configure Linux kernel (initial configuration, some required modules still may be missing).
+       apply_sysctl
 
        # Check if timezone definition is available
        if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
@@ -925,7 +924,7 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # ... and here finish configuring parameters
-       sysctl -q -e -p /etc/sysctl.conf
+       apply_sysctl
 else
        emit --no-wait root-filesystem
        emit --no-wait virtual-filesystems
index 8b25adf55f6228fb181330a5777b42b15c09658e..d918cd56e447d241b7a9c57a28aec161ce64bab6 100644 (file)
@@ -208,7 +208,3 @@ kernel.sysrq = 1
 # for mplayer
 #dev.rtc.max-user-freq = 1024
 #
-
-# protect hard/symlins
-fs.protected_hardlinks = 1
-fs.protected_symlinks = 1
This page took 0.21802 seconds and 4 git commands to generate.