1999-03-28 20:36:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
# PROVIDE: sysctl
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="sysctl"
|
|
|
|
stop_cmd=":"
|
2004-01-17 11:15:04 +00:00
|
|
|
start_cmd="sysctl_start"
|
|
|
|
reload_cmd="sysctl_start"
|
|
|
|
lastload_cmd="sysctl_start last"
|
2004-01-17 10:59:43 +00:00
|
|
|
extra_commands="reload lastload"
|
2002-07-18 05:00:17 +00:00
|
|
|
|
2008-07-31 21:57:35 +00:00
|
|
|
#
|
|
|
|
# Read in a file containing sysctl settings and set things accordingly.
|
|
|
|
#
|
|
|
|
parse_file()
|
2002-07-18 05:00:17 +00:00
|
|
|
{
|
2008-07-31 21:57:35 +00:00
|
|
|
if [ -f $1 ]; then
|
2002-07-18 05:00:17 +00:00
|
|
|
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})
|
|
|
|
;;
|
|
|
|
*)
|
2008-07-31 22:13:14 +00:00
|
|
|
if ! sysctl "${var}" >/dev/null 2>&1; then
|
|
|
|
warn "unable to set ${var}"
|
|
|
|
fi
|
2002-07-18 05:00:17 +00:00
|
|
|
;;
|
|
|
|
esac
|
2008-07-31 21:57:35 +00:00
|
|
|
elif [ "$2" = "last" ]; then
|
2002-10-25 23:02:54 +00:00
|
|
|
warn "sysctl ${mib} does not exist."
|
2002-07-18 05:00:17 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2008-07-31 21:57:35 +00:00
|
|
|
done < $1
|
2002-07-18 05:00:17 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-07-31 21:57:35 +00:00
|
|
|
sysctl_start()
|
|
|
|
{
|
|
|
|
|
|
|
|
parse_file /etc/sysctl.conf $1
|
|
|
|
parse_file /etc/sysctl.conf.local $1
|
|
|
|
}
|
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|