xref: /freebsd/libexec/rc/rc.d/sysctl (revision 732a02b4e77866604a120a275c082bb6221bd2ff)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: sysctl
7
8. /etc/rc.subr
9
10name="sysctl"
11desc="Set sysctl variables from /etc/sysctl.conf and /etc/sysctl.conf.local"
12command="/sbin/sysctl"
13stop_cmd=":"
14start_cmd="sysctl_start"
15reload_cmd="sysctl_start last"
16lastload_cmd="sysctl_start last"
17extra_commands="reload lastload"
18
19sysctl_start()
20{
21	case $1 in
22	last)
23		command_args="-f"
24	;;
25	*)
26		command_args="-i -f"
27	;;
28	esac
29
30	for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
31		if [ -r ${_f} ]; then
32			${command} ${command_args} ${_f} > /dev/null
33		fi
34	done
35}
36
37load_rc_config $name
38run_rc_command "$1"
39