kcollect - Adjust Mops right hand on graph
[dragonfly.git] / etc / rc.d / sysctl
blobdd060417bcdff55e40449ebc334eaf90b67ca72e
1 #!/bin/sh
3 # $NetBSD: sysctl,v 1.12 2002/04/29 12:10:23 lukem Exp $
4 # $FreeBSD: src/etc/rc.d/sysctl,v 1.12 2003/04/24 08:20:47 mtm Exp $
7 # PROVIDE: sysctl
8 # REQUIRE: root modules
9 # BEFORE: DAEMON
11 . /etc/rc.subr
13 name="sysctl"
14 required_files="/etc/sysctl.conf"
15 stop_cmd=":"
16 start_cmd="sysctl_start"
17 reload_cmd="sysctl_start"
18 lastload_cmd="sysctl_start last"
19 extra_commands="reload lastload"
21 sysctl_start()
23 local config extra mib val old_val output
25 if [ ! -f "/etc/sysctl.conf" ]; then
26 return
29 # NOTE: Do not miss the last line when it does not end with a LF.
30 while read config extra || [ -n "${config}" ]; do
31 case ${config} in
32 \#*|'')
33 continue
35 *[^=]=[^=]*)
36 mib=${config%=*}
37 val=${config#*=}
40 warn "invalid syntax: ${config}"
41 continue
43 esac
45 if old_val=$(${SYSCTL_N} -q ${mib}); then
46 debug "sysctl '${mib}': '${old_val}' -> '${val}'"
47 if [ "${old_val}" != "${val}" ]; then
48 output=$(${SYSCTL_W} ${mib}=${val})
49 echo ${output}
51 elif [ "$1" = "last" ]; then
52 warn "sysctl '${mib}' does not exist."
54 done < /etc/sysctl.conf
57 load_rc_config $name
58 run_rc_command "$1"