> On Jul 20, 2017, at 6:35 AM, BARDOU Pierre <bardo...@mipih.fr> wrote: > > Hello, > > Is there a way to make sysctl re-read its conf file, or even another file, > like sysctl -p does on linux systems ? > Supporting this option would be nice, as it is used by the sysctl module of > ansible.
Here's the script we call (ansible handler, or as an rdist 'special') whenever we push a new sysctl.conf. It's the same code the system runs at boot time, lifted out into a standalone script. #!/bin/sh # sysctlreload: apply sysctl.conf(5) settings. # Strip in- and whole-line comments from a file. # Strip leading and trailing whitespace if IFS is set. # Usage: stripcom /path/to/file stripcom() { local _file=$1 _line [[ -s $_file ]] || return while read _line ; do _line=${_line%%#*} [[ -n $_line ]] && print -r -- "$_line" done <$_file } stripcom /etc/sysctl.conf | while read _line; do sysctl "$_line" done