mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
d9fcd86c3a
others. In the case where it displayed warnings it would still return succesfully. Modify it so that it returns the number of sysctls that it was not able to set. Make use of this in rc.d to display only *unsuccessfull* attempts to set sysctls.
55 lines
867 B
Bash
55 lines
867 B
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: sysctl
|
|
# REQUIRE: root
|
|
# BEFORE: DAEMON
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="sysctl"
|
|
stop_cmd=":"
|
|
start_cmd="sysctl_start"
|
|
reload_cmd="sysctl_start"
|
|
lastload_cmd="sysctl_start last"
|
|
extra_commands="reload lastload"
|
|
|
|
sysctl_start()
|
|
{
|
|
#
|
|
# Read in /etc/sysctl.conf and set things accordingly
|
|
#
|
|
if [ -f /etc/sysctl.conf ]; 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 [ "$1" = "last" ]; then
|
|
warn "sysctl ${mib} does not exist."
|
|
fi
|
|
;;
|
|
esac
|
|
done < /etc/sysctl.conf
|
|
fi
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|