diff options
author | delphij <delphij@FreeBSD.org> | 2012-12-13 23:32:47 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2012-12-13 23:32:47 +0000 |
commit | 976943f3a93bdb52ea2fb077b56f27c14b99da8c (patch) | |
tree | 7538275738edecd1f058054c8be372f37d487d93 /etc/rc.d/sysctl | |
parent | 52a49d45767202eda504865adcfda6c27523ef1e (diff) | |
download | FreeBSD-src-976943f3a93bdb52ea2fb077b56f27c14b99da8c.zip FreeBSD-src-976943f3a93bdb52ea2fb077b56f27c14b99da8c.tar.gz |
Teach sysctl(8) about parsing a file (while I'm there also give it
capability of parsing both = and : formats).
Submitted by: hrs (initial version, bugs are mine)
MFC after: 3 months
Diffstat (limited to 'etc/rc.d/sysctl')
-rwxr-xr-x | etc/rc.d/sysctl | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl index 34fb3b5..cc3e801 100755 --- a/etc/rc.d/sysctl +++ b/etc/rc.d/sysctl @@ -8,51 +8,27 @@ . /etc/rc.subr name="sysctl" +command="/sbin/sysctl" stop_cmd=":" start_cmd="sysctl_start" reload_cmd="sysctl_start" lastload_cmd="sysctl_start last" extra_commands="reload lastload" -# -# Read in a file containing sysctl settings and set things accordingly. -# -parse_file() -{ - if [ -f $1 ]; then - while read var comments - do - case ${var} in - \#*|'') - ;; - *) - mib=${var%=*} - val=${var#*=} - - if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then - case ${current_value} in - ${val}) - ;; - *) - if ! sysctl "${var}" >/dev/null 2>&1; then - warn "unable to set ${var}" - fi - ;; - esac - elif [ "$2" = "last" ]; then - warn "sysctl ${mib} does not exist." - fi - ;; - esac - done < $1 - fi -} - sysctl_start() { - - parse_file /etc/sysctl.conf $1 - parse_file /etc/sysctl.conf.local $1 + case $1 in + last) + command_args="-i -f" + ;; + *) + command_args="-f" + ;; + esac + + for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do + [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/null + done } load_rc_config $name |